Server-Side Programming With PHP - I
Server-Side Programming With PHP - I
08 Server-Side Programming
with PHP – I
Names of Sub-Units
Difference between Client-side and Server-side Scripting, Structure of PHP Page, Role of Web Server
Software, PHP Syntax: Variables, Data Types, Decision and Looping with Examples, Comments in PHP,
Echo and Print, PHP Operators, PHP and HTML, Arrays
Overview
The unit discusses difference between client-side and server-side scripting. Next, the unit discusses the
structure of PHP page and role of Web server software. Then, the unit explains the different types of
syntax in PHP. Further, the unit discusses about decision making and looping statements in PHP. The
unit also discusses about comments in PHP. Then, the unit explains echo and print statements. Next,
the unit explains PHP operators and PHP with HTML. Towards the end, the unit explains about arrays
in PHP.
Learning Objectives
Learning Outcomes
https://www.php.net/manual/en/language.control-structures.php
https://www.php.net/manual/en/reserved.variables.php
8.1 INTRODUCTION
Hypertext Preprocessor (PHP) is a server-side scripting language that is used to create dynamic Web
pages. It was created by the Danish programmer, Rasmus Lerdorf, in the year 1995, and was originally
called as Personal Home Page. Lerdorf initially created a set of Common Gateway Interface binaries,
written in C language, to replace some Perl scripts in his homepage. He later combined these binaries
with his Form Interpreter (FI) to create PHP/FI. Although, not officially launched, this PHP/FI was the
first version of the PHP language. PHP/FI had the capability to communicate with database and develop
dynamic Web pages. PHP is free software released under PHP License, which does not adhere to the
GNU General Public License (GPL) norms.
It has some dependency on the web browser. It is not dependent on the web browser.
It may not require the Internet connection every time. It always requires the Internet connection.
2
UNIT 08: Server-Side Programming with PHP – I JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
HTML, JavaScript, VBScript, etc. are some of the JSP, ASP.NET, PHP, Python, etc. are some of the
examples of client-side scripting language. examples of server-side scripting language.
The following points needs to be kept in mind while working with a PHP page:
All PHP code must be enclosed within <?php. . . ?> tags
Every PHP statement must end in a semicolon
Blank lines within the PHP tags are ignored by the parser
Single line comments must be preceded by the // characters, while multiline comments must be
enclosed within a /* . . . */ comment block
3
JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Advanced Web Technologies
In this section, you learn about the following fundamental concepts of PHP:
Variables
Constants
Strings
Operators
8.5.1 Variables
At times you need to use a text or a number again and again throughout your program. In such cases,
we use variables, which act as containers to store values. In PHP, the name of a variable starts with the
$symbol. The syntax to define a variable is given as follows:
$variable_name = Value;
In the preceding syntax, variable_name is a user-defined variable that can store any type of value, such
as a string or an integer. It is important to note that PHP variables are case sensitive, which means the
variable name, $teststring , is different from the variable name, $TESTSTRING.
The following code snippet shows an example of declaring a variable using PHP script:
$mystring= "Hi from PHP";
Note that in PHP, you do not require to declare a variable in order to use it. In addition, PHP automatically
converts a variable to the correct data type on the basis of its assigned value. Some naming conventions
that must be followed while declaring a variable using PHP are as follows:
A variable name must begin with a letter or an underscore (_)
A variable name can contain alphabets (upper case and lower case both), numbers, and underscores
A variable name should not contain spaces
4
UNIT 08: Server-Side Programming with PHP – I JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
The following PHP program shows an example of assigning a value to a variable by assign by reference
method:
<?php
$name = 'Dreamtech Press'; // Assign the value 'Dreamtech Press' to $name
$alt_name = &$name; // Reference $name via $alt_name.
$alt_name = "We are $alt_name"; // Alter $alt_name
echo $alt_name;
echo $name; // $name is altered too.
?>
In the given PHP program, the $name variable is assigned a string value, Dreamtech Press, and the
$alt_name variable is assigned the reference of $name. In the next statement, the $alt_name variable
is now assigned a string We are $alt_name. The value of the $alt_name and $name variables are then
printed using the echo statement. You must note that when the value of $alt_nameis changed, then the
value of $name is also changed, as in this case both the variables print the same value.
8.5.2 Constants
Constants are identifiers that store values, which cannot be changed during the execution of the script.
You can store data, such as configuration settings, whose value does not change during the execution
of the script. Constants are also used to represent integer values with special meanings in a particular
context, such as error codes and flags. It is important to note that constants are case sensitive. By
convention, the constant identifier name is always in uppercase. Constants follow same naming rules
as variables; however, unlike variables the constant names do not start with the $ sign. A valid constant
name starts with a letter or underscore, followed by any number of letters, digits, or underscores. The
syntax to create a constant is as follows:
define ( "CONSTANT_NAME", constant_value );
In the preceding syntax, CONSTANT_NAME refers to the name of the constant and constant value refers
to the value that the constant holds. For example,
define("HELLO", hello)
define("USER_NAME", Rahul)
8.5.3 Strings
A string is a collection of characters. You can perform many operations with strings, such as converting
a lowercase string in upper case string or replacing a string with another one. You can also join two
5
JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Advanced Web Technologies
strings together with the help of the dot (.) symbol. PHP also provides some methods that are used to
handle strings. Table 2 describes some commonly used built-in string methods:
Method Description
trim() Eliminates extra spaces from start and end of a string
substr() Picks substring from a string
strpos() Locates position of substring in a string
ucfirst() Capitalizes first letter of string
substr_replace() Replaces a substring with specified string
strtoupper() Converts a string in uppercase
6
UNIT 08: Server-Side Programming with PHP – I JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Resource: Represents a special data type, which stores references to functions and resources
external to PHP. The most common example of the resource data type is a database call.
NULL: Represents a special data type that can have only one value, null. Null is not only a data type,
but also a keyword literal. A variable of the null data type is a variable that has no value assigned to
it. When no value is assigned to a variable, it is automatically assigned a value, null.
The following PHP program shows an example of determining a variable datatype using the gettype()
function:
<?php
$we_are = 'Demo'; // define string variable echo gettype($we_are); //
output: 'string'
$we_are = 99.8; // assign new integer value to variable echo gettype($we_
are); // output: 'double' unset($we_are); // destroy variable
echo gettype($we_are); // output: 'NULL'
?>
In the given PHP program, the gettype() function is used to determine the datatype of a particular
variable. The $we_are variable is assigned the value, Demo. Therefore, PHP sets the datatype of the
$we_are as string. Further, the value of $we_are is changed to 99.8 which makes it a floating point
variable. Next, the variable is destroyed using the unset() function which makes it a NULL type variable.
Functions Purpose
is_bool() Tests if a variable holds a Boolean value
is_numeric() Tests if a variable holds a anumeric value
is_int() Tests if a variable holds an integer
is_float() Tests if a variable holds a floating-point value
is_string() Tests if a variable holds a string value
is_null() Tests if a variable holds a NULL value
is_array() Tests if a variable is an array
is_object() Tests if a variable is an object
7
JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Advanced Web Technologies
The following PHP program shows the if condition having more than one statement:
<?php
$x=1;
if ($x == 1)
{
print '$x is equal to 1 <br>';
$x++;
print 'now $x is equal to 2';
}
?>
The output of the given program is as follows:
$x is equal to 1
Now $x is equal to 2
In the given PHP program, if the condition stated in the if block is true, then two messages, $ x is equal
to 1 and $ x is equal to 2, get displayed. First, the PHP parser executes the $ x is equal to 1 statement,
then increments the value of $ x by 1, and then executes the Now $x is equal to 2 statement. However, if
the condition is false, then only a blank Web page is shown as the output. You can write the conditional
statements in different ways.
8
UNIT 08: Server-Side Programming with PHP – I JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
The following PHP program shows an example to understand the script of the if-else statement:
<?php
$a=34;
$b=23;
if ($a > $b)
{
echo "a is greater than b";
}
else
{
echo "a is not greater than b";
}
?>
The output of the given program is as follows:
a is greater than b
In the given PHP program, the parser checks whether or not the condition($a>$b) stated in the if block
is true. In case the condition is true, the block of statement executes displaying the message, a is greater
than b. However, if the condition is false, then the control transfers to the else block. In this case, the
block of code inside the else block is executed, displaying the message, a is not greater than b.
9
JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Advanced Web Technologies
default: statements_n
break;
}
First the program looks for a statement in the case labels that matches with the value of condition and
execute the associated statements. If no matching label is found, the program looks for the optional
default statement. However, in the absence of default statement, the program executes the statement
given in the end of the switch statements.
The following PHP program shows an example to understand the script of the switch statement:
<?php
$flower = "rose"; switch ($flower)
{ case "rose" :
echo $flower." costs $2.50"; break;
case "daisy" :
echo $flower." costs $1.25"; break;
case "lily" :
echo $flower." costs $1.50"; break;
default :
echo "There is no such flower in our shop"; break;
}
echo "no match is found";
?>
The output of the given program is as follows:
rose cost$2.50
In the given PHP program, the $flower variable is assigned a value, rose, and then the switch condition
(value of $flower) is matched with the case value given in the switch block. If the case value matches
with the switch condition, then the control flow is transferred to the case statement. The statement
within the case block is executed and the message, Great! Ready to make calculations, is displayed as
output.
10
UNIT 08: Server-Side Programming with PHP – I JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
execution does not stop until the end of the process. Sometimes, if the while condition is evaluated and
found FALSE from the very beginning, the statements are not executed. The syntax for while loop is as
follows:
while (condition)
{
statement;
}
The following PHP program shows an example to understand the script of the while loop.
<?php
$i=1; while($i<=5)
{
echo "The number is ".$i."<br />";
$i++;
}
?>
The output of the given program is as follows:
The number is 1
The number is 2
The number is 3
The number is 4
The number is 5
In the given PHP program, the while condition evaluates whether $i is less than or equal to 5. The loop
starts with i=1. The value of i gets increased by 1 each time the loop runs. When the value of i becomes
greater than 5, the statement in the braces is skipped and the loop exits without performing any tasks.
However, the value of i is not greater than 5, the statement in the braces is executed and the loop returns
to the while statement. The process repeats until $i is greater than 5.
11
JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Advanced Web Technologies
The following PHP program shows an example to understand the script of the for loop.
<?php
for ($i=1; $i<=5; $i++)
{
echo "The number is".$i."<br />";
}
?>
The output of the given program is as follows:
The number is 1
The number is 2
The number is 3
The number is 4
The number is 5
12
UNIT 08: Server-Side Programming with PHP – I JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
In the given PHP program, the value 1 is assigned to the $i variable. The loop iterates as long as the
value of the $i variable is less than or equal to 5. After each iteration, the value of the $i variable is
incremented by 1. The statement inside the loop is executed until the condition is true.
The following PHP program shows an example to understand the script of the nested looping statement.
<?php
for($num2 = 0; $num2 <= 2; $num2++)
{
for($num1 = 0; $num1 <= 1; $num1++)
{ Inner Loop Outer Loop
echo $num2. " And ".$num1."<br/>";
}
}
?>
In the given PHP program, two for loops are used, outer and inner. In the outer for loop, the $num2
variable is initialized as zero and a condition is set to evaluate whether the value of the $num2 variable
13
JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Advanced Web Technologies
is less than or equal to 2. If the specified condition is true, that is, if the value of the $num2 variable is less
than or equal to 2, the inner for loop is executed. In the inner for loop, the $num1 variable is initialized
as zero and a condition is set to check whether the value of $num1 is less than or equal to one. If the
condition of inner for loop is true, then the value of $num1 is incremented by 1 and the echo statement
of the inner for loop displays the result to the user. When the program is executed for the first time,
the initial values of the $num2 (0) and $num1 (0) variables are displayed to the user. The inner for loop
is executed until the value of the $num1 variable does not exceed beyond 1. Once the value of $num1
exceeds 1, the control of the program is transferred to the outer for loop and checks the condition. The
process of checking the condition of the outer for loop and transferring control to the inner for loop
continues as long as the value of the $num2 variable remains less than or equal to 2. The output of the
given program is as follows:
0 and 0
0 and 1
1 and 0
1 and 1
2 and 0
2 and 1
14
UNIT 08: Server-Side Programming with PHP – I JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
break;
}
echo "The number is ".$i; echo "<br />";
}
echo " This is break statement";
?>
The output of the given program is as follows:
The number is 0
The number is 1
The number is 2
This is break statement
In the given PHP program, the 0 value is assigned to the $i variable. The loop iterates as long as the
value of the $i variable remains less than or equal to 5. After each iteration, the value of the $i variable
is incremented by 1. In this program, the for loop consists of the if condition, which contains a break
statement. The execution of the loop terminates and the message is displayed as the output, if the
condition is true.
15
JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Advanced Web Technologies
In the given PHP program, the 0 value is assigned to the $i variable. The loop iterates as long as the
value of the $i variable remains less than or equal to 5. After each iteration, the value of the $i variable
is incremented by 1. In this program, the for loop consists of the if condition, which contains a continue
statement. The current iteration of the loop is terminated, if the condition is true. The control returns to
the top of the loop, restarting the cycle once again.
16
UNIT 08: Server-Side Programming with PHP – I JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
The PHP script allows you to comment the code in the following ways:
r Using the /* and */ symbols that can comment the code of multiple lines
r Using the // symbol at the start of a code line
r Using the # symbol at the start of a code line
The following code snippet shows the use of comments in a PHP script:
<?php
/* This is comment of Type 1*/
//This is comment of type 2
#This is comment of type 3
echo "Hi from PHP";
?>
17
JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Advanced Web Technologies
String Operators
Comparison Operators
Logical Operators
Increment/Decrement Operators
Arithmetic Assignment Operators
Operator Precedence
For Example:
$my_var = 9;
$another_var = $my_var;
Both the $my_var and $another_var variables contain the value, 9. Assignment operators can also be
used in conjunction with arithmetic operators..
The following PHP program shows an example of concatenating strings using the string concatenation
operator:
<?php
echo 'We are'. 'Dreamtech India';
?>
18
UNIT 08: Server-Side Programming with PHP – I JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
In the given PHP program, the string concatenation operator is used to concatenate two strings. The
second string is appended to the end of the first string, which gives the output, We are Dreamtech India.
You can also use the string concatenation operator to concatenate the values of two variables.
An example of concatenating the values of variables is shown in the following PHP program:
<?php
$myColor='black';
echo 'My favorite color is'.$myColor;
?>
In the given PHP program, the value of the $myColor variable is appended at the end of the string, My
favorite color is, by using the concatenation operator. The echo statement now prints the string, My
favorite color is black. Let’s now learn about comparison operators.
The comparison operators are used with two operands, one to the left and one to the right of the operator.
Table 5 lists the comparison operators used in PHP:
19
JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Advanced Web Technologies
You can use increment/decrement operators with variables. An example of using increment/decrement
operators with variables is shown in the following PHP program:
<?php
$x = 19; // define variable
$y=$x++; // post increment echo $y; // output: 19
$y=++$x; // pre increment echo $y;// output:21
$y=$x--; // post decrement echo $y; // output: 21
$y=--$x; // pre decrement echo $y; //output:19
?>
In the given PHP program, the $x variable is assigned the value, 19, and then $x is assigned to the $y
variable. Therefore, now $y has value 19 and then the value of $x is incremented by 1. Now, the value
of $x is 20. The echo statement prints the value of $y as 19. This is known as post increment. In pre
increment, the value of $x is first incremented by 1 and then its incremented value, 21, is assigned to $y.
Therefore, now both $x and $y contains value, 21. The echo statement now prints the value of $y as 21.
Similarly, the post and pre decrement operations are performed in the next statements.
20
UNIT 08: Server-Side Programming with PHP – I JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Operator Description
+= Adds the value and assigns it to a variable
-= Subtracts the value and assigns it to a variable
*= Multiplies the value and assigns it to a variable
/= Divides the value and assigns it to a variable
%= Divides and assigns the modulus to a variable
.= Concatenates and assigns the value(for strings only) to a variable
You can use arithmetic assignment operators to perform various operations as shown in the following
PHP program:
<?php
$x=9;
$x+=2; //similar to $x=$x+2 echo $x; //displays 11
$x-=3; //similar to $x=$x-2 echo $x;//displays 8
$x*=2; // similar to $x=$x*2 echo $x;// displays 16
$x/=2; //similar to $x=$x/2 echo $x;// displays 8
$x%=3;// similar to $x=$x%3 echo $x;// displays 2
$x= 'We are';
$x.= 'Indians';
echo $x; // displays 'We are Indians'
?>
In the given PHP program, the $x variable is assigned a value, 9, and in the next statement, its value is
incremented by 2 and assigned to itself. Therefore, now its value is 11, which is printed using the echo
statement. Similarly, other assignment operators are used in next statements.
21
JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Advanced Web Technologies
result is then multiplied with 5 and the output is 15. If the operators have same precedence then left to
right associativity decides the order of precedence.
Table 9 lists the precedence of operators with the highest-precedence operators listed at the top of the
table and operators on the same line have equal precedence:
8.14 ARRAYS
You have already learnt that a variable is a storage area holding numbers and text. The problem is that
a variable can hold only one value at a time while an array is a special variable, which can hold more
than one value at a time. An array can hold all variable values under a single name. You can access the
values of an array by referring to the array name.
22
UNIT 08: Server-Side Programming with PHP – I JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
The following PHP program shows how to create an empty array using the array() construct:
<?php
//create an empty array
$array=array();
?>
In the given PHP program, we have created a variable named $array, which is an empty array using
array()construct. PHP provides a is_array() function to check if a variable is an array or not. The is_
array()function takes a variable as its only argument and returns a Boolean TRUE if the variable is an
array else itreturns FALSE.
The following PHP program shows how to create an array with elements:
<?php
// create an array with some element
$cars = array('Lio', 'Spark', 'Scorpio', 'Safari');
?>
In the given PHP program, we have not specified any keys (indexes). If no key is specified, PHP
automatically assigns a numeric value to the key, thus creating a numeric array. The count of the index
begins at zero (0).You have learned to create an array with elements, lets learn to print the elements of
an array.
The following PHP program shows how to print the elements of an array using the print_r() function:
<?php
// create an array with some element
$cars = array('Lio', 'Spark', 'Scorpio', 'Safari');
//print the array contents
print_r( $cars );
?>
The output of the given program is as follows:
Array ( [0] =>Lio [1] => Spark [2] => Scorpio [3] => Safari )
23
JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Advanced Web Technologies
In the given PHP program, first we create array variable $cars with elements Lio, Spark, Scorpio, Safari
and then print the elements using the print_r() function.
Note:
The print_r() function outputs human-readable information about a variable and is an excellent tool
for quicklydebugging or viewing array contents
PHP 4 has introduced a foreach construct. It provides an easy way to iterate over arrays. foreach works
only on arrays, and issues an error when you try to use it on a variable with a different data type or an
24
UNIT 08: Server-Side Programming with PHP – I JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
uninitialized variable. There are two syntaxes for define the foreach loop. Following syntax is used to
define the foreach loop:
First: foreach (array_expression as $value) {
//statement
}
Second: foreach (array_expression as $key => $value) {
//statement
}
In the preceding syntax, first forms a loop over the array given by array_expression. On each loop, the
value of the current element is assigned to $value and the internal array pointer is increased by one.
The second form does the same thing, except that the current element’s index is assigned to the variable
$key on each loop.
The following PHP program shows the use of foreach loop to traverse an array:
<?php
$students = array();
//assigning values
$students[0] = "david";
$students[1] = "kevin";
$students[2] = "julie";
$students[3] = "nayyar";
// now we will use the foreach loop to display all the students names i.e
the array alues
in one go foreach ( $students as $std_name )
{
echo $std_name . "\n";}
?>
The output of the given program is as follows:
davidkevinjulienayyar
In the above code the $std_name works as a temporary variable to get each value of array. When the
loop executes, the next available value of the array overwrites the existing value of the $std_nameand
then $std_name points to the current fetched value. It works just as walking through your array values
one by one.
Every PHP array keeps track of the current element you are working on; the pointer to the current
element is known as the iterator. PHP has a ready-made extensible tool to loop over the array elements
called ArrayIterator (new in PHP 5.0) to set, move, and reset the iterator. The ArrayIterator functions
are:
current(): Returns the element currently pointed by the iterator
reset(): Moves the iterator to the first element in the array and returns its value
next(): Moves the iterator to the next element in the array and returns its value
prev(): Moves the iterator to the previous element in the array and returns its value
end(): Moves the iterator to the last element in the array and returns its value
25
JGI JAINDEEMED-TO-BE UNIVERSIT Y
Advanced Web Technologies
each(): Returns the index and value of the current element as an array and moves the iterator to the
next element in the array
key(): Returns the index of the current element
Ans. The following PHP program displays a digital clock which displays the current time of the server:
<html>
<head>
<meta http-equiv="refresh" content="1"/>
<style>
p {
color:red;
font-size:50px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
body{background-color:yellow;}
</style>
<p> <?php echo date(" h: i : s A");?> </p>
</head>
</html>
Hypertext Preprocessor (PHP) is a server-side scripting language that is used to create dynamic
Web pages.
PHP pages are plain-text files containing PHP instructions, JavaScript, and HTML language.
Web server is a software that is used to receives request from a user for a web resource and sends
response to the user with the requested web resource through Hypertext Transfer Protocol (HTTP).
PHP allows you to create dynamic Web pages by embedding PHP scripts in an HTML page using the
<?php and ?>tags.
Constants are identifiers that store values, which cannot be changed during the execution of the
script.
A string is a collection of characters.
Conditional statements help the program to decide whether the condition given in the scrip is true
and false.
Loops execute a block of statements a specified number of times provided it is true.
The placement of one loop inside the body of another loop is called nesting. When you nest two loops,
the outer loop controls the number of iterations of the inner loop.
26
UNIT 08: Server-Side Programming with PHP – I JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
The break statement, when enter in a loop skips the remaining statements in the loop body and
breaks the loop.
The continue statement also skips all remaining statements in the loop for the current iteration, but
returns to the top of the loop and allows it to continue running.
The exit statement is used when you want to stop a program from running.
Comments are chunks of text that are ignored at the time of the execution of PHP code by the PHP
engine.
The echo statement is used to display a message on a Web browser.
The print statement also used to display message on the screen.
Operators in PHP work with operands, which specify the variables and values that are to be used in
a particular operation.
Operator precedence refers to the strength with which the two operators are bound together
The PHP code needs to be embedded in either the HTML or Extensible Hypertext Markup Language
(XHTML) language, as only these are supported by the Web browser.
8.17 GLOSSARY
Constants: These are identifiers that store values, which cannot be changed during the execution
of the script.
Conditional statements: These help the program to decide whether the condition given in the scrip
is true and false.
Comments: These are chunks of text that are ignored at the time of the execution of PHP code by
the PHP engine.
Hypertext Preprocessor (PHP): A server-side scripting language that is used to create dynamic Web
pages
Web server: A software that is used to receives request from a user for a web resource and sends
response to the user with the requested web resource through HTTP
27
JGI JAINDEEMED-TO-BE UNIVERSIT Y
Advanced Web Technologies
https://www.codewall.co.uk/5-ways-to-loop-through-array-php/
https://www.php.net/manual/en/control-structures.elseif.php
Search and enlist the differences among various versions of PHP and discuss with your colleagues.
Also, discuss the use of different type of operators in PHP.
28