Pages

Sunday, May 12, 2013

Writing Your First Program....

You’ve got PHP; you’ve got a text editor. Now all you need is a PHP program, which
you’ll create in the next few minutes. Open up your text editor, and type the following
code, exactly as shown:


<?php
echo "Hello there. So I hear you're learning to be a PHP programmer!\n";
echo "Why don't you type in your name for me:\n";
$name = trim(fgets(STDIN));
echo "\nThanks, " . $name . ", it's really nice to meet you.\n\n";
?>


A lot of this code may look weird to you, and that’s OK. You’ll understand every bit
of it soon. Right now, just get used to looking at PHP, which is quite a bit different
from HTML or JavaScript.

WARNING: 
Some of the editors you might use, like TextEdit, automatically create rich text documents.
Rich text lets you use formatting, like bolding and underlining. You don’t want that in your PHP code, so look for
the option to use plain text, which doesn’t allow formatting.
If you’re using TextEdit, choose Format➝Make Plain Text. You won’t have that option if you’re already typing in
plain text. If you’re using Notepad, rich text isn’t an option, so you’ve got nothing to worry about.

No comments:

Post a Comment