Back to DFS's PHP Page
Your First Script
Your first script will generate the traditional "Hello, World!" greeting on the command line. Follow the simple steps below.
Type
cd
to get to your home directory.
Type
mkdir PHP
to create a new directory called PHP.
Type
cd PHP
to descend into the newly created directory.
Using vi, vim or some other editor, create a new file called hello_world.php.
Type in the following lines:
<?php
echo "Hello, World!\n";
?>
From the command line inside the PHP directory which you created, type
php -f hello_world.php
Notes
- <?php informs PHP (or a server) that the following is PHP code.
- ?> informs PHP (or a server) that it has reached the end of the PHP code.
- echo is a function which outputs the specified information. Here the words Hello, World! are printed. The quotation marks enclose what is to be printed. The \n is the newline character.
- The -f you typed in the command string tells the php executable that the next element is the file to be processed.
© DFStermole: 2002
Created: 22 Sept 02
Last Modified: 22 Sept 02