List of PHP Commands

List of PHP Commands. PHP stands for a hypertext processor which is intended as a server-side scripting language for generating the web application. The PHP code is mostly embedded with HTML syntax, but it can be used for any template/theme system of the web application or available web framework, etc.

Basic PHP Commands

There are a lot of PHP commands available for use in the various environment, particularly for making one web application or embedding the entire server-side codebase with HTML language and very light to learn for the normal developer. Some of the basic PHP commands are defined below:

  1. PHP Switch
  2. PHP Loop
  3. PHP Variables
  4. PHP Operators
  5. PHP If Else
  6. PHP Include
  7. PHP Functions
  8. PHP Array
  10. PHP Redirect

1. PHP Switch

PHP is using switch case as strong, like other programming languages for evading the nested representation of multiple ‘IF ELSE’. Switch case holding multiple sets of cases, and specifying default are optional. The code structure of defining a switch case is like below:

CASE 'value 1'
[CODE] Break;
CASE 'value 2'
[CODE] Break;
CASE 'value 3'
[CODE] Break;
[CODE] }

2. PHP Loop

While Loop: PHP, while loop can be run till the specifying expression is holding as true.

while [condition]{
[code] }

FOR Loop PHP, For loop is using to run the same code for the specifying number of times.

for(expression 1, expression 2, expression 3){
[code] }

Do While Loop: PHP, Do While Loop, Similar to the while loop, the code will be run until the expression gets true value in the while loop. The main dispute with while is, the code specifying inside the do at least run one whether the expression is true or not, but while not ensure the same.

do {
[code] }while (condition) // do while loop

3. PHP Variables:

Scope of the variable: Local Scope variables are Maximum. Variable reveal inside the function are not available out of the function, on the same path variable represent outside of the function are not available inside the function. It is feasible to declare a global variable in PHP, in that instance, require to declare that variable as global respectively, or accessing the same through the global array.

Types of Variable: Variable always performed a significant purpose in any kind of programming language. PHP also does the declaration of the variable for assigning the value. One of the key features of the PHP variable is, it is not needed to declare the type of the variable. As PHP is a weekly type of language, declare variable considering type based on the prescribed value. PHP normally allowed varieties types of any variable like string, integer, float, boolean, object, resource, array, or NULL, etc.

Name of the Variable: Variable name in PHP always starts with $, served by any text or specific letter, and underscore ( _ ). PHP variable name is case sensitive, so any uppercase letter variable with the same name should be considered as a new variable.

4. PHP Operators:

Operators for combination: PHP, It is primarily a set of arithmetic operators and assignment operators. Combined operators are ‘+=’, ‘-=’, ‘=’, ‘/=’, ‘%=’.

Operators for comparison: PHP, Comparison operators are ‘==’, ‘!=’, ‘>’, ‘>=’, ‘<’, ‘<=’.

Operator for logical expression: PHP, Logical operators in PHP are ‘||’, ‘&&’, ‘and’, ‘or’, ‘xor’, ‘!’.

Operator for assignments: PHP usually uses one common operator for an assignment which is equal to (=). Left of this equal sign is the variable name and right will be the assigned value.

Operators for arithmetic operation: PHP, operators, are used for implementing an arithmetic operation in PHP. Operators are ‘+’, ‘-’,’’, ‘/’, ‘%’, ‘++’, ‘–’.

5. PHP IF Else

Conditional Judgement: For any kind of conditional specification in the programming logic PHP used the ‘if-else’ feature like any other programming language. The basic syntax of the ‘IF ELSE’ statement for PHP is:

if [condition]{
[code] }else if [condition 2]{
[code] }else {
[code] }

6. PHP Include

In PHP, INCLUDE is mostly using for adding define code in an external file with the current working file.

INCLUDE (' Enter the name of the external file like, header.php')

7. PHP Function

Maximum business logic can be defined within this PHP function.

fucnction "name of the fucnction" (arg, arg …){
[code] return "Result of the function";

8. PHP Array

The array is mostly holding various related data in a single variable. Three kinds of arrays PHP usually supported.

  • Indexed Array:  $student = array(“A”, “B”, “C”);
  • Associative Array: $score = array(“A”=>80, “B”=>90, “C”=>85);
  • Multidimensional Array: $stu_score = array($student, $score);


It is similar to the HTML form.

<form action="done.html" name="username" type="post">

10. PHP Redirect

Redirecting to a new page by below PHP commands:

header("location:' Add URL to redirect'");

Conclusion PHP Commands

PHP is now a very general programming language used by the maximum common web application. If a system is not a big business with the site security or code vulnerability then PHP will be constantly a good choice. The population of a page in PHP is very quickly rather than any programming language.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top