Unlike
constants, variables are obviously meant to be variable—they are meant to
change or be changed at some point in your program. Variables also do not need
to be defined or declared and can simply be assigned when needed. Variables can
hold either numeric or text values. Variables are denoted with a dollar sign
($) and are case-sensitive, as are constants (in other words, $dateEntered
and
$DateEntered are not the same thing). The first letter of the
variable name must be an underscore or letter and cannot be a number.
In this
exercise, you’ll add variables to your existing script.
1. Open your
text editor and make the following changes to your moviesite.php
file
(noted in highlighted lines):
<html>
<head>
<title>My Movie Site</title>
</head>
<body>
<?php
define(“FAVMOVIE”, “The Life of Brian”);
echo “My favorite movie is “;
echo FAVMOVIE;
echo “<br>”;
$movierate = 5;
echo “My movie rating for this movie is: “;
echo $movierate;
?>
</body>
</html>
2. Save the changes and access
the file in your browser. Your screen should now look like the one in FigureWritten by "Shojib"
No comments:
Post a Comment