Click to See Complete Forum and Search --> : Learning PHP faster?


deep
08-29-2003, 10:50 AM
Hi,

As you maybe noticed I keep asking alot of questions on this forum because im new to php.

I also noticed that alot of php has to do with "how many functions you actually know"... not much "programming skills" is it... just a race of how many functions you can remember :confused: ??

Any ideas on how to learn php faster? :cool:
Maybe pyro can tell us how he learned so much?

(I just read one php book through my time :p and thats not enough!! :( )

pyro
08-29-2003, 11:11 AM
It's not even so much know what functions to use as it is knowing where you can find out which functions to use. And the where is easy... http://www.php.net

That being said, it really isn't that much different from other programming languages. Once you get the logic of programming down, going from one to another is more or less just picking up the syntax/functions.

Programming PHP is much more than just being able to remember functions. You need to know how to use those functions, and what to do if there isn't a function to do exactly what you need. Though on the latter point, it is usually worth taking a look through the manual at http://www.php.net/manual/en to see if there is a function to do what you need.

Maybe pyro can tell us how he learned so much?I really haven't learned PHP as well as I would like. Still working on the language. For me, I learn it just by using it. If I were to post some of the code I wrote when I was first learning, I'm sure it would give us all a good laugh. But, by using the language, I've been able to learn not only a better style of programming, but some common pitfalls to avoid. Anyway, start with simple stuff. No sence in getting in over your head. One of the first things I wrote was a simple counter. I learned some things while writing that script that is still applicable when I program things today.

Then, another helpful thing is forums. When learning, we didn't have a PHP forums here, so I went and found a different one. Asking questions when you get stuck is good, but answering the questions that you do know might be even better. Why? Because it's a great oppertunity to get in the language using it. And perhaps the best thing is when someone comes along and posts a better way of doing it. Take a look at what you posted (or what whoever posted) and then take a look at the better script. Look for what they did differently in the script.

deep
08-29-2003, 03:01 PM
I will definetly remember remember some of that you shared there, thanks.

Maybe i can help someone with a sinple script later ;). I havnt really been using php.net much but I will deffinetly take a good look at it from now on.

Have you read any good php books that you can recommend?

pyro
08-29-2003, 03:19 PM
I've have two books on PHP: PHP for the World Wide Web, and PHP Advanced for the World Wide Web. I wouldn't really recommend either of them all that highly. The former book (which is what got me started on PHP) has a few problems. Namely the fact that it is written with the assumption that global variables will be availabe. And, since they have been turned off by default since PHP 4.2.0, this could probably cause problems for those just starting off with PHP. Even if their server would happen to have registered globals turned on, one still should not use them...

I've heard lots of good things about "Beginning PHP 4" (http://www.amazon.com/exec/obidos/tg/detail/-/1861003730/103-3338550-2523851?vi=glance) though I've never seen it, so I can't verify that. I do know that that book also uses global variables so you'll have to get around that. This (http://www.webdevfaqs.com/php.php#globalvariables) might help you out there... I've also heard good things about PHP Bible (http://www.amazon.com/exec/obidos/tg/detail/-/0764549553/qid=1062188069/sr=1-1/ref=sr_1_1/103-3338550-2523851?v=glance&s=books) and PHP and MySQL Web Development (http://www.amazon.com/exec/obidos/tg/detail/-/067232525X/qid=1062188100/sr=1-1/ref=sr_1_1/103-3338550-2523851?v=glance&s=books).

deep
08-29-2003, 03:44 PM
Ok, ill look in to some of those books and see what they can offer. In the mean time i came across another little problem :D

I just opened a file and printed it on my page using the echo command and this is a peace of that text (a review of max payne)

>>>>>>>>>>

Game-play

Superb if your are an adventure/shooter fan. With a unique \"bullet time\" mode
you have the capability to dodge bullets and make devastating attacks upon
your enemy. The game lingers on like some story line from a soap opera, yet
it is enjoyably and tricky at times. You may find yourself constantly wanting
to find out more behind the sinister plot of your enemies.
Although this was possibly the most amazing game I had ever played in my life
(and that\'s no lie) I found that after I had flayed it and completed it about
8 times, I was completely sick and tired of it. But then that\'s just me, the
fans of the shooting games will love this. (it\'s a third person shooter)


>>>>>>>>>

Do you notice the \ that appears next to every " and ' ?
Thats annoing...
How do I remove all the \ ?

Oh, lets say you dont know the answer, how would you look for it? (would be good to know :) )

Thanks.

Da Warriah
08-29-2003, 03:50 PM
well, if you go to http://www.php.net and search in their function search for "slashes", then youd find stripslashes() (http://ca3.php.net/manual/en/function.stripslashes.php), which will take out slashes that are escaping another character (in this case, the quotes)...

pyro
08-29-2003, 03:56 PM
Assuming I didn't know what to do, I would do is go to http://www.php.net and look in the documentation under the string functions (http://us2.php.net/manual/en/ref.strings.php) (as we want to remove the slashes from the string). Then, I would see stripslashes() (http://us2.php.net/manual/en/function.stripslashes.php) and take a look, as it sounds like it could be what we need (and is).

Alternately, if there were no stripslashes, I would write a regexp that replaces all the slashes with a blank space. It would look like this:

$str = preg_replace("/\\/","",$str);

But, since there is a function to do just that, we'll want to use it... :)

deep
08-29-2003, 04:43 PM
Ill remember that, thanks!

pyro
09-01-2003, 10:00 PM
Actually, the code I posted above isn't what you would want, as it would replace all backslashes, not just the ones around quotation marks. This would be better. Sorry about the code above:

$str = preg_replace("/\\\\\\('|\")/","\\\\1",$str);