Introduction to PHP 8/13
Variables
So far we've been outputting strings and doing math.
To do more complex coding, we need a way to "save" these values. We can do this usingvariables. A variable can store a string or a number, and gives it a specific case-senstive name.
Examples:
$myName = "Beyonce";
$myAge = 32;
All variable names in PHP start with a dollar sign (
$
).
Instructions
On line 8, create a variable named
$myName
and set it equal to your name. Make sure to end your PHP code with a semicolon.<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p>
<?php
$myName = "Beyonce";
$myAge = 32;
?>
</p>
</body>
</html>
Comments
Post a Comment