To add php code to a page use these tags:
<?php
and
?>
The first of these opens php code, the second closes it.
To send a piece of text to a web browser use:
<?php
echo 'Hello World';
?>
To send quotation marks inside a quoted string use '\' as an 'escape' character.
<?php
echo 'Hello World\'s End';
?>
The word 'print' can be used instead of 'echo'.
<?php
print 'Hello World\'s End';
?>
The 'printf' function is used for formatted output (here we see the origins of PHP in the C language).
To start a new line in PHP output use <br />:
<?php
print 'Hello <br />World\'s End'
?>
This shows how a HTML tag can be included inside an echo or print function in php. It is thus possible to write pages to a web browser that contain no direct html tags and which have no tags inside the
when the source is viewed.We can now format text using a style sheet for the <p> tag:
<?php
print '<p>Hello World\'s End</p>'
?>