Revision:
code <div> <?php echo "My first PHP script!"."<br>"; echo "Hello World"."<br>"; ECHO "Hi, there"."<br>"; eCHo "Hope you are doing fine"; ?> <h4><?php echo "PHP syntax" ?></h4> <?php echo "PHP syntax"; ?> <?php $message = "Hello"; echo $message; ?> </div>
codes:
<div>
<?php
echo "hello world"."<br>";
print "fine to get the opportunity"."<br>";
$color = "red";
echo "<br>";
echo "my car is ".$color."<br>";
echo "my car is ".$COLOR."<br>";
echo "my car is ".$coLOR."<br>";
echo "<br>";
$txt = "hi there, my world!";
$x = 5;
$y = 6;
echo $txt;
echo "<br>";
echo $x;
echo "<br>";
echo $y;
echo "<br><br>";
$txt = "playing soccer";
echo "I love $txt!";
?>
</div>
$variable_name = value;
code: <div> <?php $color = "red"; $COLOR = "green"; $coLOR = "white"; echo "My car is " . $color . "< br>"; echo "My house is " . $COLOR . "< br>"; echo "My boat is " . $coLOR . "< br>"; $title = "PHP is awesome"; echo $title; ?> <?php $txt = "Hello world!"; $x = 5; $y = 10.5; echo $txt ."< br>"; echo $x ."< br>"; echo $y ."< br>"; ?> <?php $txt = "my website"; echo "I love $txt!"."< br>"; echo "I love " . $txt . "!"."< br>"; $x = 5; $y = 4; echo $x + $y; ?> <?php $title = "PHP is fun!"; ?> <h4><?=$title?></h4> </div>
Variable xx inside function is:
Variable xx outside function is: 5
Variable yy inside function is: 5
Variable yy outside function is:
<div> <?php $xx = 5; // global scope function myTest() { // using x inside this function will generate an error echo "< p>Variable xx inside function is: $xx< /p>";// use of unassigned variable "$xx"; } myTest(); echo "< p>Variable xx outside function is: $xx< /p>"; ?> <?php function myTest_a() { $yy = 5; // local scope echo "< p>Variable yy inside function is: $yy< /p>"; } myTest_a(); // using yy outside the function will generate an error echo "< p>Variable yy outside function is: $yy< /p>"; ?> <?php $x_x = 5; $y_y = 10; function myTest_b() { global $x_x, $y_y; $y_y = $x_x + $y_y; } myTest_b(); echo $y_y; // outputs 15 ?> </div>
A constant is simply a name that holds a single value. The value of a constant cannot be changed during the execution of the PHP script.
To define a constant, you use the define() function, which takes the constant,s name as the first argument and the constant value as the second argument.