Knowledge base: Using PHP
- What is PHP?
- What version of PHP do you run on your service?
- How do I create a PHP script that will run on my site?
- Can I run PHP in CGI mode?
- Where can I get good PHP scripts for my web site?
- What are the best places and ways to learn more about PHP?
-
What is PHP?
PHP is a server-side, cross-platform, HTML embedded scripting language, which allows you to create dynamic web pages. PHP use and popularity is growing rapidly on the web as more and more people discover PHP's powers and how it is a robust and high performance alternative to ASP. It is also very easy to get started with. PHP-enabled web pages are easy to create and are treated just like regular HTML pages by the server. You can create and edit them the same way you normally create regular HTML pages. Most PHP pages mix embedded PHP statements into regular HTML code. PHP allows you to generate web pages quickly from components, which may be other PHP files, database queries, template files and so on. PHP is very fast and transparent to the web visitor - the dynamic pages are usually created and delivered just as fast as regular HTML. PHP is one of the best and easiest ways of interfacing your web site with a database back end (on our service this would be MySQL).
-
What version of PHP do you run on your service?
All our servers run PHP 4, latest stable release.
-
How do I create a PHP script that will run on my site?
You should create your PHP file with a .php extension. For example, if you wanted a PHP-enabled home page, you should call it index.php
Embedded PHP code needs to be placed within <?php ?> tags. For example:
<?php
PHP code goes here
?>
See here for a good beginners tutorial on PHP.
-
Can I run PHP in CGI mode?
Yes, you can run PHP in CGI mode if you wish. This allows PHP to take advantage of our SuExec CGI wrapper, which provides for increased security. In this mode, PHP is handled identically to Perl, except you should place the following as the first line of your code:
#!/usr/local/bin/php
You must also name your file with a .cgi extension (instead of .php) and make sure it is user-executable and not in a world-writeable directory - just like any other CGI script. In other words, follow the same instructions as for CGI, as detailed in our CGI section.
-
Where can I get good PHP scripts for my web site?
A good place to start looking for PHP scripts are the following sites which list a large number of freeware, shareware and commercial scripts covering all sorts of applications:
PHP Resource Index http://php.resourceindex.com/Complete_Scripts/
Open Source Development Network http://www.freshmeat.net -
What are the best places and ways to learn more about PHP?
As well as an increasing body of books on the PHP language, there are an ever-growing number of useful web sites dedicated to learning and using PHP. Some that we would recommend are:
PHP.net http://www.php.net
PHP Resource Index http://php.resourceindex.com
ALT-PHP-FAQ http://www.alt-php-faq.org