Jump to content
Sign in to follow this  

Beginning To Learn Php

Recommended Posts

This post will bore to death anyone with just a little PHP knowledge!! I am in the process of learning PHP, using the book "PHP 4 Bible". The book doesn't offer "lessons" or "projects" to learn by, so I thought I'd create my own and share. Like I said...the first several will be VERY BASIC. Please feel free to correct me of any errors, offer further knowledge, or ask questions.


Doing posts like this will help me learn what I'm reading, and maybe it will help someone else out there too!! So, here goes:


Lesson 1: PHP with HTML


PHP and HTML go hand in hand. You can literally take an already designed HTML page and add the PHP

scripts. So how would you do this? You use special tags to "escape from HTML" into PHP and then back

into HTML. You can do this an unlimited number of times within a page. There are four sets of tags

that you can use.



><?PHP    ?>

This is the tag you should use unless you have special reasons for using another set. If you

use this tag, you can be certain that your PHP will be interpreted correctly every time.



><?       ?>

This is the shortest tag of them all, but requires certain steps be accomplished before it can be

used appropriately. Additionally, support was not enabled in the beta versions of PHP 4.



><%       %>

This style also requires accomplishing some steps before it can be used successfully.



><script language="php"></SCRIPT>

This style can be cumbersome in certain situations and is best used with fairly sizable blocks of

PHP code. Be careful if you use lots of Javascript as the close script tags are fatally ambiguous.


Additionally, every PHP statement is terminated by a semi-colon! The script will not work without the

appropriate semi-colons.


Now, it is time for the first lesson. Open a new file in your preferred editor and type the following code.

NOTE: You can use this particular PHP script within normal HTML structure or as stand-alone code. If

you use it within the HTML structure, place the code within the body tags.



	 print (5+5);	//PHP statement(always terminated by semi-colon)

The result will simply be a page generated with the number "10" in the upper left hand corner.

Fairly simple and boring example, but it does illustrate how to use the PHP tags.


Reference for all above material is "PHP 4 Bible" by Tim Converse and Joyce Park; ISBN 0-7645-4716-X

Share this post

Link to post
Share on other sites

Not a problem!! I just hope someone out there benefits as much from reading the lessons as I will from writing them.


Tracy Goof

Share this post

Link to post
Share on other sites

Tracy, I just subscribed to your 'course'.

Lesson 1 is all right, so keep up the good work!

Share this post

Link to post
Share on other sites

Thanks for the note. Just to let you know, and anyone else who is interested, I will probably not be able to post the third lesson until sometime next week. I am going on a camping trip this weekend and have much preparation to do. Just didn't want anyone to think that I decided to stop what I'd started. I'm determined to make it all the way through the book, with at least one post per chapter.


Thanks again,


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this