Category Archives: PHP

PHP echo and print statement

003 – PHP echo and print statements

In PHP the echo and print statements are two basic ways of getting output.

They both output data on the screen but there are three small differences between them.

  • The echo statement has no return value while the print statement has a return value of 1, so it can be used in expressions.
  • The echo statement in PHP is a little bit faster than the print statement.
  • The echo can take multiple parameters while the print statement can take only one.

Continue reading

PHP variables

002 – PHP Variables

In PHP, variables start with $ followed by the name of the variable. You don’t need any command or keyword for declaring variables in PHP.

Like in any other programming language, there are rules for declaring variables in PHP. Variables in PHP must start with a letter or an underscore sign. They can’t start with a number. A PHP variables can contain only letters, numbers and/or underscores (alphanumeric characters). They are also case sensitive.

<!DOCTYPE html>


$a = "Hi there!";
$A = 5;
$_ = 10.5;
$_a_b = "What a name!";

echo $a;
echo "<br>";
echo $A;
echo "<br>";
echo $_;
echo "<br>";
echo $_a_b;
echo "<br>";



Continue reading

This entry was posted in PHP on by .