PDA

View Full Version : My PHP Learning Experience


Cap Ologist
03-29-2005, 11:35 PM
A couple of weeks ago I discovered an online gangster game. After spending some time playing this game I realized that I was becoming intrigued with the php language. I went to Half Price Books and looked through some resources there and then Barnes and Noble.

A couple of months ago, I started another programming dynasty that died. Hopefully, I'll have better success with this.

I'm working through a book called "Sam's Teach Yourself PHP, mySQL and Apache". I've used books from Sam's Teach Yourself series in the past, and have found that they explain things in a way that I can grasp.

The first couple of chapters deal with setting up a programming environment on your computer/server. I'm not going to bore you with too many of those details.

Chapter 5 is where I'm going to pick up. This chapter si called "The Building Blocks of PHP". It deals mainly with variables and data types. I read through it pretty quickly, alot of it was familiar with a few changes that I picked up pretty quickly. One thing I like about PHP already is how it handles variables. In other languages that I have experience with like Java and Visual Basic, you have to declare what kind of data type the variable you are using is. For example, in Visual Basic, I would write Dim nNumber As Integer. In PHP however, variables are prefaced with a $ and the language figures out what data type should be used. I'm going to use a naming convention I've used in the past with my variables so that I can easily identify what's going on. I'm going to add the lowercase first letter of the data type immediately after the $, so if I was planning on the variable referring to a string, it would be known as $sName.

Chapter 6 is about Flow Control Functions such as if-thens, loops, and switches. This is a chapter I paid a little more attention to because there are some technical nuances that are different from Visual Basic, which is the language I have been working with most recently. Most of this was still pretty straightforward.

Chapter 7 deals with functions which are used in programs to pass information to different parts. This was one of the hardest things for me to understand several months ago, but having been exposed to Java and Visual Basic, it was pretty easy for me to see what was going on here.

Here (http://www.dreamjobdevelopments.com/history.html) is a sample PHP program that I've written. It will tell you the final score of all 39 Super Bowls. I wrote to practice some of these things that I've been learning (declaring variables, a switch loop, and passing of data) while using somethings (forms) that I've mainly skimmed over. Forms are still a chapter or two away. So go ahead, and check out my Super Bowl program.

That's what I've gone over the last two days. My plan is to work through at least one chapter a week. Right now, most of the material is somewhat familiar, but I'm anticipating some difficulty especially when I get into work with databases. I haven't messed with databases in any form since my sophomore year of college about 7 years ago.

sabotai
03-30-2005, 12:02 AM
Just to give you some alternative reading sources in case you want to have multiple sources (always a wise choice), here are the PHP (and related) books that I have that I recommend.

Web Database Applications With PHP and MySQL by Williams and Lane (O'Reilly book)
Programming PHP by Lerdorf and Tatroe (O'Reilly book)
PHP Cookbook by Sklar and Trachtenberg (O'Reilly book)
PHP And MySQL Web Developement by Welling and Thomson (not an O'Reilly book :) )

Of course, I'm not saying go out and buy all of these, but they're worth looking through at the bookstore and if you want 1 or 2 more sources.

Good luck with this. I'll be following.

Cap Ologist
03-30-2005, 12:15 AM
Thanks, I'll keep my eye out for those. If Barnes and Noble have them, I'll probably spend some time there looking through them.

Alf
03-30-2005, 02:54 AM
Welcome to the bright side CapOlogist ! (Edit , check my sig, the Francestats-ht link goes to a web based php+mysql stats site I have built using primarily www.php.net and www.mysql.com + a few advice from online guys)

Cap Ologist
04-03-2005, 06:33 PM
Let's see, this past chapter was on arrays and objects. Arrays are very simple, they are very similar to what I've been exposed to in the past. Objects have always been somewhat confusing to me, but I think I began to see through the fog as I was going through the chapter. I'll probably spend some more time on objects in the next couple of weeks.

One question I have about associative arrays. Is it possible to step through them with loops? Meaning, I have an array of "name", "age", and "college". Can I set a loop to go through them as array(0), array(1), etc. or does the language no longer recognize the index values? I hope that makes sense enough for someone to explain it to me.

If anybody knows a good website or other resource about object oriented programming, I'd appreciate the info. I really want to make sure I understand all the ins and outs of OOP.

Dutch
04-03-2005, 09:28 PM
I am getting in to PERL and PHP looks very similar, as I suspected. Cool! I'll be following along.

Alf
04-05-2005, 03:17 AM
Cap, there is the function : foreach for what you want to do. A must with arrays if you want to do anything.

http://fr.php.net/manual/en/control-structures.foreach.php

Dutch : PHP is Perl for noobs (just like me, and I like it)

Dutch
04-05-2005, 11:51 AM
Isn't PERL easier than PHP?

Alf
04-06-2005, 02:27 AM
Isn't PERL easier than PHP? For my personal experience, I would say no, but I am no programmer, and I use PHP combined with MySQL to build a stats site (check my FranceStats linky). And it is efficient enough and clear enough.

bw1488
04-13-2005, 12:48 AM
Wow,Deja Vu.I myself found an online gangster game(omerta) and like it alot,but I thought to myself there is so much more they could do with it.So i got a hold of a friend of mine and he sent me the source code for an MMORPG that he used to build a game that is inplay at this moment,and I said to myself.I'm gonna learn this php stuff and make some changes and adjustments to make this D&D type game into a gangster game the way I think it should be,this was 4 days ago.If you like I could send you the source code for the game so you can see what its like.I don't have a clue about programming myself,but I have been looking for some stuff to help me learn it and boom here you are and you've given me the advice I need on where to go for the help.

primelord
04-13-2005, 10:12 AM
Isn't PERL easier than PHP?
Dutch,

They are actually very similar. I also wouldn't say either is really harder than the other. FWIW I am pretty good with Perl. If you have any questions along the way I would be happy to help.

Dutch
04-15-2005, 10:23 PM
Thanks Primelord, it's appreciated. I may not have any questions for a while. I'm just getting into it and the tutorials I have are fairly easy to follow so far (http://learn.perl.org/library/beginning_perl/). I know it will get a bit tougher later on.