PHP First Program

Syntax

See the below table to get the opening and closing tags of php

Opening Tag Closing Tag
<?php ?>
<? ?>
<script language=’php’> </script>

PHP echo

The echo statement insert text into a web page. It is the common statement in php. We can echo a statement using following types

  • Single Quotes
  • Double Quotes
  • Without Quotes
  • “here document” method

Sample 1

<?php
echo 'Hello World';	// Single Quotes
echo "Hello World";	// Double Quotes
echo 12345;			// Without Quotes
echo <<<END
Hellow World
END;
?>

Sample 2:

<?php
//method 1
echo "Hellow World";
?>
<?
//method 2
echo "Hellow World";
?>

<script language='php'>
//method 3
echo "Hellow World";
</script>

Sample 3:

<html>
<body>
<h1>
<?php echo "PHP With HTML!"; ?>
</h1>
</body>
</html>
This entry was posted in PHP and tagged .

Leave a Reply

Your email address will not be published. Required fields are marked *