to Write PHP Code?
A PHP script starts with <?php and ends with ?>.
It can be placed anywhere in the program.
First we will start with a simple PHP code to print “This
is my first PHP program”.
The extension of the file is given as .php.
<?php echo “This is my first PHP program.”?>
Result: This is my first PHP program.
echo is used to give the
A comment is the portion of aprogration which only meant
for human reader.Its only purpose is to read by someone who is looking to your
Comments can be used to:
others understand what you are doing
yourself what you did.
# This is single line cmment
// This is also single line comment
/* This is multi lines comment
Purpose:Multi lines Comment*/
is Case sensitive
Yes PHP is case sensitive. Try Out yourself:
print(“Variable capital is $text<br>”);
print(“Variable capital is $Text<br>”);
Variable capital is 50
Variable capital is
In PHP echo and print both are used to display
output.Both of them more or less are same.
The main difference between echo and print is that:
not return any value but print return value 1 in
expression. Let’s see some examples:
text using echo:
echo "Hello world!";
Variable using echo
echo $a+ $b;
text using print:
print "Hello world!<br>";
Variable using print:
print $a+ $b;