Variables are containers for your data. For example, I can say that the variable $student is set equal to "Julio Garcia."
$student="Julio Garcia";
I can then tell PHP to print($student); and PHP will print: Julio Garcia.
print($student);
For example: variables.php
<html>
<head>
<title>variables.php</title>
</head>
<body>
<?php
$student="Julio Garcia";
Print($student);
?>
</body>
</html>
You can also do the following:
$number1=10;
$number2=15;
$number3=5;
print("The sum of ".$number1. ", ".$number2.", and ".$number3. " is:"; print($number1+$number2+$number3);
For example:variables2.php
<html>
<head>
<title>variables2.php</title>
</head>
<body>
<?php
$number1=10;
$number2=15;
$number3=5;
$total=$number1+$number2+$number3;
print("<p>The sum of the numbers is ".$total."</p>");
print("I have ".($number1+$number2+$number3)." dollars!");
?>
</body>
</html>
|