Learn Basics of PHP programming language

Learn the Basics of PHP programming language: PHP is called a personal home page. and it's a base of the internet. so today we are going to learn the basics of PHP programming language. 

Introduction to PHP programming language.

PHP programming is a Server Side open-source Scripting language that is embedded in HTML programming language. it is used to create dynamic web pages. all the PHP scripts are executed on the server. it's developed by Rasmus Lerdorf in 1994.

learn basics of php programming language

Why we need to learn PHP?

Because PHP is capable of generating dynamic page content, creating, opening, reading, writing, deleting, and closing files on the server. it has more secure to write code in PHP. it has encrypted data and controlling user access. and there is a lot of requirement of PHP developers. and also it's used by the world's largest social network Facebook and WordPress's biggest blogging system on the web. also, it's running on varying platforms, like Windows, Linux, Unix, and mac os. it's also compatible with almost all modern servers. it also supports a wide range of databases.

Basics of PHP

<?php ...write your php code...  ?>
All the php code are written between the <?php and ?> tag. we can also use the <? ...write your php code..  ?> tag to written our php code.

echo :

It's a built-in function and a language construct. it's used to output the text or content.we can also add the HTML code in the echo statement.

//comments :

A comment is a line that is not executed by the compiler in a program. we just only include the comments to given instructions to the other users so they can easily understand our code. one other thing is that it's a single line comment. we cannot add multiple lines of comments in the program using this syntax.

/* .... write your code ......

........   */
This is a multi-line comment. we use this syntax to add multiple lines of comments.

$variable_name :

In PHP we use this syntax to declare a variable. in PHP, variables are used to store information. a PHP variable should start with a dollar($) sign.

Constants :

constants are similar to variables but the only difference between the variables and constants is that the value of a constant cannot be changed or undefined.

define() :

This a function that is used to define the constant variable it's has three parameters, first name, the second is value, and third is case-insensitive.

Integer :

An integer is a whole number without decimals that can contain positive or negative numbers.

Float :

A float is a floating-point number, which includes a decimal point numbers.

Boolean :

A boolean variable can only have two values one is TRUE and the second is FALSE.

String :

Strings are the variables which are the combinations of characters.

Variable Scope :

The scope of a variable is the part of the script in which the variable can be referenced or used. there are mainly two types of variable scopes available one is local, second is global. 

Global Scope :

A variable declared outside a function has a global scope and a global variable can access from anywhere of the script.

Local Scope :

A variable declares within a function has a local scope, and can only be accessed within that function. and a local variable can only be accessed inside the function where it can declare another wise it produces the error. 

Variable variables :

In PHP, we can use one variable to specify another variable's name. it's the most important concept in PHP. 

Arithmetic Operators :

The operators can perform arithmetic operations like addition, subtraction, multiplication, and soon. an arithmetic operator works with numeric values to perform common arithmetical operations. 

Assignment Operators :

An assignment operator is used to assign values to variables or used to write values for variables.

Logical Operators :

A logicla operator are used to combine conditional statements or performs logical operations. 

Array :

An array is a user-defined variable that can hold more than one value at a time. 

Numeric/Indexed array :

Numeric array stores the values using the numeric index. the indexed can be assigned automatically or starts from zero(0) and incremented by one. 

Associative array :

Associative arrays are arrays that store the values using the named keys which can be assigned by the user. 

Multi-dimensional array :

A multidimensional array contains more than one array. 

If Else statements :

The if-else statement is used to execute certain code if a condition is true or not. 

While loop :

The while loop executes a block of code as long as the specified condition is true. 

Do-while loop :

The do-while loop will always execute the block of code once, and check the condition and repeat the loop as long as the specified condition is true. 

For loop :

For loop is used when you know how many times the script should run. 

Switch statement :

the switch statement is used cases or blocks to run a specific code. 

break statement :

break keyword is used to break a condition when a condition is true or not and switch out the compiler out of the loop.

continue :

continue statement is used to continue the loop or statement when a specified condition is true. it continues the loop without executing the code. 

include :

The include statement allows for the insertion of the content of one PHP file into another PHP file. 

Functions :

A function is a block of statements that can be used to perform a specific type of condition. 

return :

A return statement is used to return a specific type of output by a function. 

GET method :

This keyword is used to send information from user to server. but when we send the information via the GET method then it visible to everyone because that all the values of variables are displayed in the URL of the page. 

POST method :

This keyword is used to send information from user to server. and when we send the information via the POST method then the information is not visible to everyone.

Session :

We use the session to store information in variables to be used across multip pages. 

Cookies :

A cookie is a small file that the server embeds on the user's computer. which is used to identify the user when the user returns to the website. 


it's used to access global variables from anywhere in the PHP script. 


it's used to collect data after submitting the form. 

Files :

PHP files are used to store information from the user. we use files for any purposes. 

Classes :

classes are used to describe the object's blueprint, description, or definition. it describes the object's features that what object able to do. 

Object :

objects are used to create a copy of the class and used to access the features of classes. 

Constructor :

a constructor is a function that can call automatically whenever a new object is instantiated. 

Destructor :

a destructor is a function that can call automatically whenever a new object is destroyed. 

Inheritance :

when a class inherits the methods and properties of another class this type of feature is called inheritance. 

Abstract Classes :

an abstract class can be inherited but they cannot be instantiated. 

Static keyword :

A static keyword defines static properties and static methods. 

Final keyword :

A final keyword defines methods that cannot be overridden in child classes. and the final classes cannot be inherited. 


when a variable is created without a value, it's automatically assigned a value of NULL.

Please do like and share this post with your friends and your social media handles. this will give me good confidence to create such more posts like this.
Learn the Basics of PHP programming language
Previous Post
Next Post

Yash is a Full Stack web developer. he always will to help others. and this approach takes him to write this page.

Related Posts