Changes

Creating a Simple PHP Script

7 bytes added, 13:56, 13 May 2009
no edit summary
</pre>
<google>ADSDAQBOX_FLOW</google>
This PHP script calls the built-in PHP ''phpInfo()'' function, the purpose of which to output information about the PHP pre-processing module integated integrated into your web server.
Save this file as phpInfo.php and upload it to a location on your web server where it will be accessible via a web browser. Once you have done this open a browser and go to the URL for this file. If all is well with your PHP installation you will see several pages of detailed information about your PHP environment covering topics such as how and when the PHP module was built, the version of the module and numerous configuration settings.
If you do not see this information it is possible you do not have the PHP module integrated into your web server. If you use a web hosting company, check with them to see if your particular hosting package includes PHP support (sometimes PHP support is only provided with premium hosting packages so you may need to upgrade). If you run your own web server consult, the documentation for your particular type of server (Apache, Microsoft IIS etc) for details on integrating the PHP module. There are vastly superior resources available on the internet to assist in installing PHP than we could never match in this book.
A healthy PHP installation should result in output similar to the following:
[[Image:Php_simple_example.jpg]]
If you see something like the above in your browser then you have succesfully successfully created and executed your first embedded HTML script.
If you do not see the expected output in your browser window then go back and check your file. Something as simple as a missing character can result in no content being generated by the PHP module. As you will learn with experience, problems are almost always the result of subtle mistake mistakes in entering the PHP code.
== Embedding HTML into a PHP Script ==
== Summary ==
In this chapter we have looked at how to test that the PHP module is installed into the web server and functioning correctly. We then went on to look at how to add PHP scripts to a web page. In the next chapter we will look at the all important, but all too frequently neglected, topic of [[Commenting PHP Code|adding comments to PHP code]].