|
|||||
|
Useful Links Graphic Design
Websites Web Services Our Projects |
A Short PHP Tutorial... Courtesy: www.php.net Here we would like to show the very basics of PHP in a short, simple tutorial. This text only deals with dynamic web page creation with PHP, though PHP is not only capable of creating web pages. See the section titled What can PHP do for more information. PHP-enabled web pages are treated just like regular HTML pages and you can create and edit them the same way you normally create regular HTML pages. What do I need?In this tutorial we assume that your server has activated support for PHP and that all files ending in .php are handled by PHP. On most servers, this is the default extension for PHP files, but ask your server administrator to be sure. If your server supports PHP, then you do not need to do anything. Just create your .php files, put them in your web directory and the server will automatically parse them for you. There is no need to compile anything nor do you need to install any extra tools. Think of these PHP-enabled files as simple HTML files with a whole new family of magical tags that let you do all sorts of things. First:Create a file named "hello.php" and put it in your web server's root directory (DOCUMENT_ROOT) with the following content:
<html>Will display:
<html>This program is extremely simple and you really did not need to use PHP to create a page like this. All it does is display: Hello World using the PHP echo() statement. Note that the file does not need to be executable or special in any way. The server finds out that this file needs to be interpreted by PHP because you used the ".php" extension, which the server is configured to pass on to PHP. Think of this as a normal HTML file which happens to have a set of special tags available to you that do a lot of interesting things. Next - Get system information from PHP
<?php phpinfo(); ?>
We won't show you the result for our server as it may open up a few security holes, however this will show you all of your server's php configuration - very useful for debugging and when you need to know certain variable value of your server. Let's do something more useful...Let us do something more useful now. We are going to check what sort of browser the visitor is using. For that, we check the user agent string the browser sends as part of the HTTP request. This information is stored in a variable. Variables always start with a dollar-sign in PHP. The variable we are interested in right now is $_SERVER['HTTP_USER_AGENT'].
<?php echo $_SERVER['HTTP_USER_AGENT']; ?>
Should display what browser you are using: CCBot/1.0 (+http://www.commoncrawl.org/bot.html)
AND
<?php echo $_SERVER['REMOTE_ADDR']; ?>
Should display your IP address: 38.103.63.61
As you can see PHP is a very, very powerful programming language and can turn a simple HTML website into something quite spectacular! - Here at Avera we have ben writing websites with PHP since 1997 and we find it the most versatile and simple language to learn. See www.php.net for more information... |
||||
Avera (Business) Solutions Limited - Telephone: 0845 120 5188- Email Us: info@avera.co.uk
All Prices On This Website Exclude VAT. Design © Copyright 2008 Avera. Images © Copyright Their Respective Owners. All Rights Reserved. | Avera Solutions Limited