-
Web Hosting
-
Domain Names
-
Support
You are here:
Scripting with Perl & PHP
How to create a PHP script
How to create a PHP script
Applies to: Dynamic Hosting, Premium Hosting, Unlimited Hosting
PHP is a general purpose scripting language that is well suited to web development and can be embedded into HTML. If you want to find out more about PHP take a look at is extensive online manual.
You can use any plain text editor to create a PHP script (e.g. Windows - notepad, Mac – textedit). Lets take a look a a very simple PHP script:
<?php echo “Hello World!”; ?>
Line 1 - This tag tells the server that you are writing PHP code
Line 2 - You can use the echo function to print out a string of text, this will be displayed back when the script is run.
Line 3 - This tag tells the server that you have stopped writing PHP code
Note
Each line of PHP code is called a statement, and ends with a semi-colon to signify it is a complete statement.
Open your text editor and type the code above into it (without the line numbers), and save it to a file called hello_world.php.
Next upload your hello_world.php script to your web hosting using FTP.
Now load up the script in your web browser e.g. http://www.domain.com/hello_world.php (replace domain.com with your domain name). If all goes well you should see 'Hello world!' at the top of your screen. If not check out the PHP Troubleshooting guide.
