PHP Tutorial – Part 1 of 5

Published on Mar 12, 2007   //  Tutorials

PHPWhat is PHP?
PHP stands for PHP Hypertext Preprocessor. PHP is a programming language which allows you to create web applications. PHP is widely used by many developers and is a very easy language to learn to use. There is lots of documentation on PHP at there site on how to use PHP.

Using PHP and HTML Together
You can mix PHP and HTML together in on page. PHP complies or runs on the server before sending to the browser so mixing PHP together with HTML is not a problem. For PHP to work on our servers you will need to save your files with a .php extension instead of a .html (or .htm).

Try the following example. Open up your notepad and enter the following:

 [code='php']



[/code]

Save the file as example.php and upload it to your site. You will see that it outputs in bold Hello World. The print command lets you simply display text or variable on the screen. Notice how the PHP is encased with <?php and ?>. Also make note that after each php line you should have a semicolon.

Stay tuned as we will continue this tutorial with more details on using PHP.

3 Comments to “PHP Tutorial – Part 1 of 5”

  • Mine said “hello word”

  • Yep, it would have, since there’s a typo in the PHP script posted. :P Doesn’t matter though, it’s still the same example.

    Although, I guess this is more personal coding practices, function names should be all lowercase.

    Also, parentheses are optional on the “print” function (same with echo).

    I, personally, prefer echo over print. Echo is actually more flexible in that you can have it output more than one string, so you could have:

    echo “The Date Is” . $date;

    Or:

    echo “The” . “Date”. “Is” . “$date”;

    Etc.

    I guess it just depends on what you want to do, but I almost always use echo, besides, I don’t want to get them mixed up and try to pass multi-string arguments through print. :P

  • Yes it worked, im using PHP triad and i have used this method before.