PHP 101: PHP For the Absolute Beginner

This area is intended for everyone new to PHP. It opens with a series of informal, entertaining tutorials written by Vikram Vaswani, founder and CEO of Melonfire. These tutorials build on a previously-published 5-part series which has now been updated and extended to embrace PHP 5, making parts of it suitable for those of you who already have worked with PHP 4 in the past.

If you came here to learn about elementary PHP 4 or basic PHP 5, this is for you. Enjoy!

Published: December 19th, 2011 at 21:00
Categories: Tutorials
Tags: , ,

48 comments to “PHP 101: PHP For the Absolute Beginner”

Very socked to read that Php is used as object oriented programming language.
I want to know the difference between PHP3,PHP4 and PHP 5.

Thanks
Preeti

Highly recommended, and even funny to read. The "my standard response" example is genius :)

Where do i go next? Php.net manual?

_____anonymous_____
October 8th, 2006 at 1:10 am

Thank you very much for such an interesting PHP Tutorial.
10/10
:)

I Read all the content for the ZEND’s PHP Tutorial

Its really amazing and its very esily understandable

i really know lots of things about php

its wonderful

amzing work by ZEND!
I really THANK YOU and WISH
ZEND TEAM

I took 24 hrs off from my uni work just to learn php and i #
wentthrough each of the tutorials. They were absolutely easy
to understand and the humour in it really makes a person to
readit.
I understood the OOP nature of php as ive coded in C++
java before. and php has the easiest syntax. What a language
Easiest scripting language ever thanks to zend. I am now starting to progress into more advanced tutorials. Keep up
the good work

_____anonymous_____
November 10th, 2006 at 3:21 pm

This tutorial looks excellent, but the font size is way too small. I am very concerned about the trend to smaller and smaller font sizes in ALL web pages, but this particular tutorial could be improved by making the font larger. When printed, it is nearly impossible to read; it’s barely readable in a browser (and yes, I am using FireFox’s ability to expand fonts, but that doesn’t help when printing). Thanks!

_____anonymous_____
January 6th, 2007 at 4:34 pm

This is an excellent tutorial. I already have some programing experience. So the concepts are not new to me, but you help me see and understand the implementations in PHP very well.

_____anonymous_____
February 11th, 2007 at 8:32 pm

ARE YOU AN INSTRUCTOR? YOU SHOULD BE!!! YOUR PHP TUTORIALS HAS BEEN VERY INTERESTING AND INFORMATIVE. I’M GETTING READY TO DO MY FIRST CODE

I was referred to your tutorials by a programming professional. I consider that to be very high praise, indeed.

Having nothing more in the way of coding experience than an online course I took in HTML 4.0, I am in desperate need of finding gainful employment.

I was not thrilled with the prospect of returning to the workforce as a secretary, but my programmer friend informed me that your site would be a wonderful place to begin learning PHP. And he was RIGHT!

The sense of humor evidenced in the lessons makes the learning lighthearted and fun. I’m very excited to pursue this course of study and become truly proficient in it.

Many thanks for all the work that was put into this series. It really shows and I am extremely grateful you’ve made it available.

_____anonymous_____
July 13th, 2007 at 4:29 am

I’ve worked with html, perl, javascript.. all in small projects, a few for business, most for personal interest. I haven’t touched php/mysql in about a year after doing some simple stuff, so really needed to refresh on the entire concept of php, its functions, classes, etc.

Dude, your presentation of the material was perfect. I read every lesson this evening, over a 3 hour time frame, and it’s definately put me back on track. Thank you so much for your selfless approach to help others. It was done in a clear, concise, and very effective way.

that’s very helpful
thanks a lot

_____anonymous_____
August 16th, 2007 at 4:05 pm

Thanks for laying these lessons out in such an easy-to-understand-format. I hope you don’t mind if I link to you. I use <a href="http://www.squidoo.com/modxcms">MODx CMS</a> and created a one-page overview for people to get a basic understanding of this content management system. I’m so glad I found you on Digg today!

_____anonymous_____
August 28th, 2007 at 7:33 pm

Your php tutorials are lucid, thoughtful, and thorough. Your humorous tone is a rare asset and much wellcomed. I usually do not comment on the internet but when I see so many people thanking you for sharing your knowledge and goodwill I can not help but add my gratitude for your kidness. Farewell and consider writing the tutorials as a little book!

I am beginning to try and use php and have had no experience in programming before except for html and was looking for a more professional robust language to use and have found it with php. I found that your tutorial was one that I could sit down quite easy and read the whole thing from beginning to end which I did the first time round. But alas you can’t take all that information in with just one sitting you have to keep coming back, but with this tutorial I really don’t mind. You take the boredom out of learning and create fun ways to explain your ideas and I hope you carry on your tutorials to succeed in a healthy and wealthy career.

Just wanted to say thanks for the helpful tutorials.. While I generally prefer using Ruby on Rails to develop web apps, a host I am working with does not offer that option, so PHP it is! <b> Comment by Robert H. Goretsky of Hoboken, NJ </b>

Just wanted to say thanks for the helpful tutorials.. While I generally prefer using Ruby on Rails to develop web apps, a host I am working with does not offer that option, so PHP it is! Comment by Robert H. Goretsky of Hoboken, NJ

Its really amazing and its very easily understandable.
Amazing work by ZEND!

_____anonymous_____
October 8th, 2007 at 3:46 am

For of all, great article(s)! But a PDF version of all the chapters would been even better!

I am very new to PHP technology and using PHP5 for development of e-commerce appliations. So i often need an online help while completing my coding. So these articles makes my coding work very easy and headche free.
Thanks
sanjay patil(web pulse technologies)

_____anonymous_____
October 17th, 2007 at 8:10 pm

This really is a wonderful resource. I would love to see it accessible via PDF (maybe charge a couple bucks?) as I don’t have regular access to the internet.

Thanks for providing this tutorial!

_____anonymous_____
December 8th, 2007 at 8:30 am

its the one of best guide for php learners thnx dude and keep it up! :)

_____anonymous_____
March 14th, 2008 at 5:32 am

hi alex you can just save the page as html so it can be accessible offline.

or bookmark it then choose "Make Available Offline"

It’s just perfect … I would be very glad if there were an PDF version avaliable for download.
Anyway , like i said before : PERFECT.
Better than the itself PHP.net.

Thanks Zend Team.

_____anonymous_____
September 1st, 2008 at 9:17 pm

I have been using other languages for a few years now and never had anything like this to help with them. I praise you for putting this up as I am just now starting to learn PHP.

_____anonymous_____
September 3rd, 2008 at 8:08 am

grateful that u have provided me with such a beatiful and simple tutorial i was in search of such tutorial for long time and again thank you thanks a lot

i’ve been wanting to learn PHP for some time now. i started putting little peices together, but that was as far as i could go. i have driven my friends nuts asking questions. i am going to post a link to this tut on our community page, bluesfear.com/forums.

again, thanks tremendously

I’m a web developer that is doing some teaching on the side. These are a set of excellent tutorials. I have been using a modified version to teach my classes.

Thanks

_____anonymous_____
November 5th, 2008 at 10:52 am

Hai, i’m newbie in php and i got a little problem. i try this syntax :

<html>
<head>
<basefont face="Arial">
</head>
<body>

<?php

// set database server access variables:
$host = "localhost";
$user = "root";
$pass = "marais";
$db = "testdb";

// open connection
$conn = mysql_connect($host, $user, $pass) or die ("Unable to connect Database!");

// create database
mysql_create_db($db) or die ("Unable to create database!");

// create query
$query = "CREATE TABLE alamat (
nama VARCHAR (25) NOT NULL,
alamat VARCHAR (60) NOT NULL,
telpon INT (11) NOT NULL,
id INT (3) UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id)
)";

$hasil = mysql_db_query($db,$query);

if ($hasil) {
echo "Tabel <b><i>alamat</i></b> dalam <b>$db</b> berhasil dibuat!";
}else{
echo "Tabel <b><i>alamat</i></b> dalam <b>$db</b> gagal dibuat!";
}

?>

</body>
</html>

but all i get is an error message :

Fatal error: Call to undefined function mysql_create_db() in C:\htdocs\bikindb.php on line 19

am i doing it wrong?

_____anonymous_____
January 25th, 2009 at 12:44 am

Amazing tutorial. Keep it up, mate. 11/10.

It all worked fine until I reached the following line.
INSERT INTO symbols VALUES (1, ‘America’, ‘eagle’);

and I got an error message:
ERROR 1146 (42S02): Table ‘world.symbols’ doesn’t exist

Could anyone please help with this?

Thanks,

_____anonymous_____
March 6th, 2009 at 3:34 pm

For all those who have enjoyed this tutorial as much as I have:

The above will download a zip file with a FULL PDF version of this tutorial and the original code for parts 14 and 15…..

Finished creating this today!! hope Vikram Vaswani doesn’t mind me doing this but was getting bored of the broken links in the tutorial…

ENJOY!!

http://www.bms.co.uk/downloads/other/PHP101.zip

_____anonymous_____
March 20th, 2009 at 2:25 pm

I tried to access http://www.bms.co.uk/downloads/other/PHP101.zip but get a page not found error. also tried it as /php101.zip Has the updated file been removed?

_____anonymous_____
May 5th, 2009 at 11:35 pm

Is there a link to the tutorial source code!? Help!

bill dot clerico at gmail dot com

thanks!

_____anonymous_____
June 19th, 2009 at 7:15 am

Just wanted to commment on what a nice tutorial you put together. Everything is well explained in layman terms and it’s an easy read. Highly recommended for the php newbie!!!

First of all thanks everyone for preparing such wonderful tutorial.
Then, here I ask experts, if they mind, after finishing this, what would be their recommended material for going through more of PHP and advanced levels?
Any answer would be appreciated.

This is science at it’s best! My quest for global domination starts here!

Look at this line:

for($x = 0; ($x > array_count_values($each_pet)); $x++) {

This loop will never be run, since $x = 0, and array_count_values($each_pet) will never be smaller than zero.

Between this tutorial and the php tutorial at http://bright-tutorials.com/2009/12/introduction-to-phpmysql/ I have now learned the uses and ways of generating php pages with and without the help of MySQL. Thank you!

First time i enjoy a tutorial like this:). Really well done with many straightforward examples and jokes all over the place.

Thank you for your great posts.

Many of them help me a lot.

Thanks for this. give me a lot.

Thank you for this good guide to learn.

I’m really loving reading your PHP tutorials. Great work!!!

Many Many Thanks to you for this amazing post,
i have a hunger of learning new things, and now days i want to learn php so your article will help me a lot…
thanks for sharing with us….

http://www.onlinecheapatvs.com/

When I was stumbling with learning the basics of web development a few years ago, I came across these tutorials after several attempts and no success at learning PHP. I’m now a contracted web developer and web application development teacher to several students in my spare time. If it weren’t for this series of tutorials, I never would have been able to take my first step.

Thank you.

Like I said above, I do really love your tutorials.

Need to go over the previous one but this is what the real guide is for me that’s helping me be allot more secure with my PHP applications, though I do think I am quite lazy myself i.e. I thought about not checking each individual element in the $_POST array, to use a loop to work out this for me.

This is what I tend to do now (granted you can’t tell the user which element is the problem, or can you?) anyways here’s what I came up with myself, follows a bit of modified logic off you’r example at the start:

<html>
<head>
<title></title>
</head>

<body>
<?php

// this checks for null values and only allows user to enter string data?

if(array_key_exists(‘submit’, $_POST)) {

foreach($_POST as $key=>$value) {
if(strlen($value) === 0) {
$error = ‘You missed out some required fields, please try again’;
}
}

} else {
// show the form anyhow below:
$message = ‘Please enter a comment in the form below:’;
}
?>
<?=(isset($message)) ? "<p>$message</p>\n" : ” ?>
<form action="<?=$_SERVER['PHP_SELF'];?>" method="POST">
<p>
<label for="comments">Please enter a comment here: </label><input type="text" id="comments" name="comments" /><br>
<input type="submit" id="submit" name="submit" value="Post Comment" />
</p>
</form>
<?=(isset($error)) ? "<p>$error</p>\n" : ” ?>
</body>
</html>

I just loved these tutorials!

Thanks a lot!