Forums | MacLife
You are not logged in.
#1 2007-12-21 12:20 am
- Light Speed
- Doubter of Einstein

- Registered: 2002-08-17
- Posts: 3693
Best way to learn PHP5 for myself
Alright I have beeen hacking apart other people's PHP apps for over 4 years now and still have not learned how to make my own from scratch.
I know I know WTF?!?!?!
Can anybody recommend an online tutorial that goes through step by step and worded for noobies that covers requires, DB connections, working with arrays from DB tables that was written in this century?
Most of what I have found in Google searches is incomplete or ancient.
Also is PEAR MDB2 a prefered route? I am looking to limit the opportunity for injection as I am a noob and will probbaly screw something up and leave a huge HACK ME HERE NOW PLEASE sign 
Offline
#2 2007-12-21 7:04 am
- Booksley
- Planely insane!
- From: Toronto, Ontario
- Registered: 2001-02-16
- Posts: 4826
Re: Best way to learn PHP5 for myself
According to one of my friends, just using PHP is a huge HACK ME HERE NOW PLEASE sign 
Offline
#3 2007-12-21 3:40 pm
- Light Speed
- Doubter of Einstein

- Registered: 2002-08-17
- Posts: 3693
Re: Best way to learn PHP5 for myself
Booksley wrote:
According to one of my friends, just using PHP is a huge HACK ME HERE NOW PLEASE sign
LOL 
Offline
#4 2007-12-21 4:42 pm
- Antonio
- Now with more cowbell!

- From: San Francisco, CA
- Registered: 2007-01-16
- Posts: 520
Re: Best way to learn PHP5 for myself
There are ways of making PHP secure. JSP is more secure out of the box, but we'll not start the entire "which is better for middle to back end scripting" debate. A PHP site can be made to be as secure.
I think if you can learn how to hack and edit PHP apps, then you probably know it well enough to get up to speed building your own PHP stuff pretty quickly, as you probably wouldn't be hacking it with much success if you didn't understand the nuts and bolts well enough to do so.
Also, PHP has a fairly easy learning curve...
have you tried PHPmac or the PHP Wikibook?
“The most merciful thing in the world, I think, is the inability of the human mind to correlate all its contents.”
--HP Lovecraft, The Call Of Cthulhu
Offline
#5 2007-12-21 4:59 pm
Re: Best way to learn PHP5 for myself
Visual Quickstart guides are a great way to learn.
And there will only be a big "hack me" sign if you don't learn about the security implications of taking in data. I could make any language a security nightmare - so anyone who singles out one language is just trying way too hard to be funny and probably needs to be slapped.
Probably what a lot of people don't understand about PHP is that it doesn't do anything for you - its just a long list of functions that you can choose to work with in any way you choose, so its easy to choose the quick route that doesn't take any security into account.
So, just when did this place get Private Messages? YIKES!
Gippy Pages | Fuzzy Coconut XHTML Widget | PuppyCam
Offline
#6 2007-12-21 10:26 pm
- Light Speed
- Doubter of Einstein

- Registered: 2002-08-17
- Posts: 3693
Re: Best way to learn PHP5 for myself
Thanks guys!
PHP Wikibook has a lot of up to date info that will be helpful.
I have used Visual Quickstart in the past for learning other stuff and wasn't thinking about them but you made me dig a little more and I found this which has an online version too!!
Now I have work to do! 
Yeah I know my way around existing apps and hacked a custom wholesale area into my x-cart install but that is just taking existing code and reworking it to do what I want without knowing how to write that code in the first place and I am at point where I need to to know what I am doing for real. These resources will help!
Offline
#7 2007-12-22 2:26 am
Re: Best way to learn PHP5 for myself
Booksley wrote:
According to one of my friends, just using PHP is a huge HACK ME HERE NOW PLEASE sign
No, it's not.
There is some very bad code because php is easy so people who don't understand security can write apps.
Use suhosin - http://www.hardened-php.net/suhosin/
It will protect you from many attacks.
Understand that you need to verify far more than most people think. For example - the session id (if using sessions) can be manipulated by the user, as can many of the http environmental variables.
Be extremely cautious when granting write access to the webserver user. In many cases, it is better to do an sql insert rather than write to filesystem. When you do need to write to filesystem, do so in a directory outside of the web root (so that any file written to file system can not then be requested by users browser) etc.
It's not a bad to forbid the system and exec calls in your php.ini.
You probably don't want to use them (there almost always is a better way) and many exploited php sites are exploited because un-checked input was allowed to send an exec command to the php interpreter.
I'm not a guru by any means, but php can be done safely and there are a lot of programmers who do so. There are just far more who don't, and they write exploitable code no matter what language they are using, they just happen to often use php because it is so easy.
I bought the php 5 mysql bible.
It's a good book. At least I think so.
Last edited by resedit (2007-12-22 2:29 am)
I think the obvious question everyone has is who takes loaded weapons into a Toys R Us? -- Jim Ferguson
Offline
#8 2007-12-22 3:13 am
- avkills
- demyelinated brain matter

- Registered: 2001-05-09
- Posts: 6534
Re: Best way to learn PHP5 for myself
Well you also need to check input so they don't hose the SQL calls also. I bought the O'reilly book "Learning PHP5."
and they are all right. PHP is easy as pie if you have done any other sort of programming.
-mark
Offline
#9 2007-12-22 6:38 pm
Re: Best way to learn PHP5 for myself
avkills wrote:
Well you also need to check input so they don't hose the SQL calls also.
Yeah - there's a function called mysql_real_escape_string that should be used before running a query.
http://us3.php.net/mysql_real_escape_string
I think the obvious question everyone has is who takes loaded weapons into a Toys R Us? -- Jim Ferguson
Offline
#10 2007-12-23 3:02 am
Re: Best way to learn PHP5 for myself
resedit wrote:
avkills wrote:
Well you also need to check input so they don't hose the SQL calls also.
Yeah - there's a function called mysql_real_escape_string that should be used before running a query.
http://us3.php.net/mysql_real_escape_string
Also just abstracting your code properly and validating is imperative.
Offline
#11 2007-12-23 4:12 am
- Antonio
- Now with more cowbell!

- From: San Francisco, CA
- Registered: 2007-01-16
- Posts: 520
Re: Best way to learn PHP5 for myself
resedit wrote:
Booksley wrote:
According to one of my friends, just using PHP is a huge HACK ME HERE NOW PLEASE sign
No, it's not.
There is some very bad code because php is easy so people who don't understand security can write apps.
Indeed.
“The most merciful thing in the world, I think, is the inability of the human mind to correlate all its contents.”
--HP Lovecraft, The Call Of Cthulhu
Offline

