A Walk Through PHP
PHP pages are HTML pages with PHP commands embedded in them. This is in contrast to many other dynamic web-page solutions, which are scripts that generate HTML. The web server processes the PHP commands and sends their output (and any HTML from the file) to the browser. Example 1-1 shows a complete PHP page.
Example 1-1. hello.php
<html>
<head>
<title>Look Out World</title>
</head>
<body>
<?php echo 'Hello, world!' ?>
</body>
</html>Save the contents of Example 1-1 to a file,
hello.php, and point your browser to it. The
results appear in Figure 1-3.

Figure 1-3. Output of hello.php
The PHP echo
command produces output (the string
“Hello, world!”), which is inserted
into the HTML file. In this example, the
PHP code is placed between
<?php and ?> tags. There
are other ways to tag your PHP code—see Chapter 2 for a full description.
Configuration Page
The
PHP function phpinfo( ) creates an HTML page full of information on how
PHP was installed. You can use it to
see whether you have particular extensions installed, or whether the
php.ini file has been customized. Example 1-2 is a complete page that displays the
phpinfo( ) page.
Example 1-2. Using phpinfo( )
<?php phpinfo( ); ?>
Figure 1-4 shows the first part of the output of Example 1-2.

Figure 1-4. Partial output ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access