Using Variables in PHP
To assign a value to a variable,
the =
sign is used, which is called
the assignment operator. Let's, for example, assign
the number 3
to the variable $a
:
<?php
$a = 3;
?>
Now let's output the contents of the variable $a
to the screen using the echo
command:
<?php
$a = 3;
echo $a; // will output the number 3 to the screen
?>
Create a variable $num
and assign
it the value 123
. Output the value
of this variable to the screen using the
echo
command.