Simple Programs for display Statements in PHP
Syntax of PHP:
<?php
// PHP code goes here
?>
Example 1:
<!DOCTYPE html>
<html>
<body>
<?php
echo "My first PHP script!";
?>
</body>
</html>
Output:
My first PHP script
Example 2:
Comments Program:
<!DOCTYPE
html>
<html>
<body>
<?php
// This is a single line comment
# This is also a single line comment
/*
This is a multiple lines comment block
that spans over more than
one line
*/
?>
</body>
</html>
Example 3:
<!DOCTYPE html>
<html>
<body>
<?php
$color="red";
echo "My car is " . $color .
"<br>";
echo "My house is " . $COLOR .
"<br>";
echo "My boat is " . $coLOR .
"<br>";
?>
</body>
</html>
Output:
My car is red
My car is red
My car is red
Example 4:
<!DOCTYPE html>
<html>
<body>
<?php
ECHO "Hello World!<br>";
echo "Hello World!<br>";
EcHo "Hello World!<br>";
?>
</body>
</html>
Output:
Hello
World!
Hello
World!
Hello
World!
// PHP code goes here
?>
<html>
<body>
<?php
echo "My first PHP script!";
?>
</body>
</html>
<html>
<body>
<?php
// This is a single line comment
# This is also a single line comment
/*
This is a multiple lines comment block
that spans over more than
one line
*/
?>
</body>
</html>
<html>
<body>
<?php
$color="red";
echo "My car is " . $color . "<br>";
echo "My house is " . $COLOR . "<br>";
echo "My boat is " . $coLOR . "<br>";
?>
</body>
</html>
<html>
<body>
<?php
ECHO "Hello World!<br>";
echo "Hello World!<br>";
EcHo "Hello World!<br>";
?>
</body>
</html>
No comments:
Post a Comment