Programming computers is simple! Let’s dive in and write a simple script that outputs a line of text to your monitor.
<?php echo "What day is it today?"; ?>
If you save the above lines in a text file and name it someday.php, you have a PHP script ready for execution.
You can run it from the command-line and it will look something like this:
> php someday.php What day is it today?
This script consists of one line of actual PHP code, between two special-purpose tags, namely
<?php
and
?>
These tags demarcates the beginning and the end of your script and must always be present in PHP script files.
The only line that actually does something, is
echo "What day is it today?";
The line starts with a so-called language construct, called echo. Echo will output the next parameter to the screen. Then comes a text string — that’s our question to be output by echo: “What day is it today?”, in quotes. Text strings must always be quoted in PHP.
Also pay attention to the semicolon at the end of the line. In PHP, lines have to end with semicolon, and if you forget it you’ll get an error message.
Not too excited, huh? Well, here’s the deal: If you came this far, you’re really on the move! Now, you can get your computer to do almost anything you want.