I'm only new to this big wonderful world of PHP. I did some programming when I was younger, but that was only in Turbo Pascal, and was highly limited in what the programs could achieve. For years afterwards, I never pgorammed again...but that's all changed now.
See, every programing language seemed too hard to learn before now, and what with school and owrk commitments, I could never seem to find the time to commit to learning it. That's all changed since I discovered PHP. PHP would have ot one of the easiest and most flexible programming languages I've ever seen. It's a dream to code in, even if it's error detection system is a little bit vague as to where in the script the error was actually occuring.
I recently finished my first mid-scale, expandable script, and at Tyberius Prime's suggestion I'm now writing this bit of a faq about my experiences. I leanred many important things while writing this script, things that will stay with me forever, and hopefully I won't make the same mistakes twice...no...I've done that already. Ok, so hopefully I won't make the same mistakes a 12th time.
Now Why Didn't I Think Of That?
Ok...my frist mistake was so obvious that I didn't even notice it until a friend of mine pointed it out to me. So...valuable lesson number one...
If you're going to try and reference an internal variable, make sure you define it and give it a value first. Obvious mistake, I know, but the obvious ones are sometimes the hardest ones to spot.
How One Small Character Can Cause So Many Problems
How was I to know? I thought I'd finally gotten this script written, and the time had come to test it out. So I fired up Apache, locaded up my web-browser, navigated to my script and...
"PHP ERROR: PHP Parse Error on Line 12"
Great...what the hell does that mean? Go back, check the source code...ok...line 12, line 12...yeah...ok. Nothing wrong there.
Or so I though...there was but one character missing there. The one character which I'm assured is very, very important in the writing of most programming languages...the humble semicolon.
How was I to know that this was my problem? It was, however, missing almost everywhere in there, and it is most definatley needed, so...that's another lesson learned.
No Matter How You Write It, There's Always Going To Be A Better Way To Do It...
Ok...bitdamaged pointed out to me the more clunky or obsolete parts of my code, for which I thank him, and he also pointed out to me how I could change it to have it work better. This was yet another valuable lesson...always ask questions about what you're writing, becuase sure as hell, though you may think you have the best way of doing it, there is always someone out there who knows a better way.
These are only a few things that I encountered along the way, I had a few other problems, mainly involving formatting my code so that it didn't interpret the apce between <img and src=" as a new line (beleive me, that took a while)...but I've got to leave you a few lessons ot learn on your own.
The most important lesson that came from this experience though? Tyberius Prime, Perfect Thunder, Petskull, DL-44 and bitdamaged...they are really the pelple to ask...they know their stuff, and at least one fo the mwill have an answer for you. Ask question, then ask some more, ask questions about the answers to the previous set of questions, then ak some more questions...it's the best way to learn.