Pages

Sunday, May 12, 2013

This program does just a few simple things:

1. Identifies itself as PHP using <?php
2. Prints out a welcome message using the echo command
3. Asks the visitor for his name, again using echo
4. Gets the visitor’s name and stores it in something called $name
5. Says hello by printing out a message followed by what’s in $name
6. Finishes up with the ?> characters
It’s okay if a lot of this doesn’t make sense, but you probably already could have
figured out a lot of this, except maybe the weird line beginning with $name =. There
are also some strange characters, like \ns and STDIN, that you’ll learn about soon.
Just see if you can follow the basic path of things: the opening <?php, the printing,
the request for the user’s name, another bit of printing, and the closing ?>.
Now save this program. Name it sayHello.php, and make sure you add that .php
extension. Otherwise you’ll have problems down the line. Save the file some place
handy, like on your desktop, in your home directory, or in a folder you’re using to
keep all your PHP programs in as you’re learning.

That’s it; you’ve written your first PHP program!

No comments:

Post a Comment