PHP Programming
900 subscribers
54 photos
1 video
7 links
PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.

PHP is a widely-used, free, and efficient alternative to competitors such as NodeJs or Microsoft's ASP.
#PHP #Tutorials #course

Join Now!
@php_tut
Download Telegram
Channel created
PHP - What is OOP?

OOP stands for Object-Oriented Programming.

📌 Procedural programming is about writing procedures or functions that perform operations on the data,

📌 while object-oriented programming is about creating objects that contain both data and functions.

@php_tut
"w3schools .com"
Object-oriented programming has several advantages over procedural programming:

OOP is faster and easier to executeOOP provides a clear structure for the programsOOP helps to keep the PHP code DRY "Don't Repeat Yourself", and makes the code easier to maintain, modify and debugOOP makes it possible to create full reusable applications with less code and shorter development time

📌 Tip: The "Don't Repeat Yourself" (DRY) principle is about reducing the repetition of code.
You should extract out the codes that are common for the application, and place them at a single place and reuse them instead of repeating it.

@php_tut
"w3schools .com"
PHP - What are Classes and Objects?

Classes and objects are the two main aspects of object-oriented programming.

📌 A class is a template for objects, and an object is an instance of class.

@php_tut
"w3schools .com"
OOP Case

Let's assume we have a class named Fruit. A Fruit can have properties like name, color, weight, etc. We can define variables like $name, $color, and $weight to hold the values of these properties.

When the individual objects (apple, banana, etc.) are created, they inherit all the properties and behaviors from the class, but each object will have different values for the properties.

@php_tut
"w3schools .com"
Define a Class

A class is defined by using the class keyword, followed by the name of the class and a pair of curly braces ({}). All its properties and methods go inside the braces:

@php_tut
"w3schools .com"
📌 Above we declare a class named Fruit consisting
of two properties
📌$name
📌$color

and two methods
📎set_name()
📎get_name()

for setting and getting the $name property.

@php_tut
"w3schools .com"
PHP Arrays

📌An array stores multiple values in one single variable.

What is an Array?

📌An array is a special variable, which can hold more than one value at a time.

If you have a list of items (a list of car names, for example), storing the cars in single variables could look like this:

----------------------------------
$cars1 = "Volvo";
$cars2 = "BMW";
$cars3 = "Toyota";
---------------------------------

However, what if you want to loop through the cars and find a specific one? And what if you had not 3 cars, but 300?

The solution is to create an array!

An array can hold many values under a single name, and you can access the values by referring to an index number.

@php_tut
"w3schools .com"
In PHP, there are three types of arrays:

#1. Indexed arrays - Arrays with a numeric index

#2. Associative arrays - Arrays with named keys

#3. Multidimensional arrays - Arrays containing one or more arrays.

@php_tut
"w3schools .com"
Create an Array in PHP

In PHP, the array() function is used to create an array

------------------------------------
$names = array("Abas", "John", "Elias");
------------------------------------
@php_tut
"w3schools .com"
Secure Login system using PHP with MYSQL database

https://youtu.be/TytaDtwnj0o
PHP Comments

Comments in PHP

A comment in PHP code is a line that is not executed as a part of the program. Its only purpose is to be read by someone who is looking at the code.

Comments can be used to:

💎Let others understand
your code

💎Remind yourself of what you did - Most programmers have experienced coming back to their own work a year or two later and having to re-figure out what they did. Comments can remind you of what you were thinking when you wrote the code.

📌PHP supports several ways of commenting:

#1 Syntax for single-line comments:
💎 using #
💎 using //

#2 Syntax for multiple-line comments:
💎 /* */

@php_tut
"w3schools .com"
Online Book Store - PHP & MYSQL Project

https://youtu.be/IMCHi-5Ig40