34,333
edits
Changes
no edit summary
In this chapter we will look at constructing the most basic of PHP examples, and in so doing we will take two approaches to creating PHP powered web content. Firstly we will look at embedding PHP into an HTML page. Secondly, we will look at a reverse example whereby we embed the HTML into the PHP. Both are perfectly valid approaches to using PHP.
== The PHP Code Delimiters ==
The first thing to understand is the need to use PHP code delimiters to mark the areas of PHP code within the web page. By default, the opening delimiter is ''<?php'' and the closing delimiter is ''?>'' (later in this chapter we will look at changing these delimiters). You can insert as many insert as many or as few blocks of PHP into a web page as you need as long as each block is marked by the opening and closing delimiters.
A sample PHP script block would, therefore, appear in an HTML file as follows:
<pre>
<?php
echo '<p>This is a PHP script</p>';
<?>
</pre>