amuck-landowner

Good resources for learning PHP?

marlencrabapple

New Member
Not sure how if its your post language, but coming from c# and Perl php.net was more than enough to help me figure things out. I already avoided most of the bad practices by doing web dev in Perl first, so a refrerence for function names and weird php oddities was really all I needed.
 

scv

Massive Nerd
Verified Provider
Might be construed as irrelevant to the question, but I'd suggest straying away from PHP. The core design of the language is severely flawed and despite their recent move to resolve some of these problems, what makes PHP PHP is also what makes PHP bad. The effort required to write "good" PHP could easily be applied to learning another language.

There are plenty of choices for doing web development efficiently nowadays. My first suggestions would be Python, Perl, or even Ruby. You can get into stranger and more obscure choices from there.
 

SrsX

Banned
Might be construed as irrelevant to the question, but I'd suggest straying away from PHP. The core design of the language is severely flawed and despite their recent move to resolve some of these problems, what makes PHP PHP is also what makes PHP bad. The effort required to write "good" PHP could easily be applied to learning another language.

There are plenty of choices for doing web development efficiently nowadays. My first suggestions would be Python, Perl, or even Ruby. You can get into stranger and more obscure choices from there.
I have to disagree with your statement here.

It's not the fact it's flawed, it's the fact people don't learn how to use it to the full extent and give up early (at least, that's my personal view behind it).
 

Aldryic C'boas

The Pony
It's not the fact it's flawed,
Umm.. sorry, but it kinda is.  I could likely fill several pages with problems I've come across with PHP (problems with the language itself, mind you);  but quite honestly so many people have done the same at this point that it's easier to reference existing lists.  Such as this one:  http://toykeeper.net/soapbox/php_problems/

3.3, 5.2, 10, 17, and 20 from that list are my pet peeves, and why I stick to Perl and Python when possible.
 
Last edited by a moderator:
  • Like
Reactions: scv

raindog308

vpsBoard Premium Member
Moderator
Umm.. sorry, but it kinda is.  I could likely fill several pages with problems I've come across with PHP (problems with the language itself, mind you);  but quite honestly so many people have done the same at this point that it's easier to reference existing lists.  Such as this one:  http://toykeeper.net/soapbox/php_problems/

3.3, 5.2, 10, 17, and 20 from that list are my pet peeves, and why I stick to Perl and Python when possible.

#15 is my favorite on that list.  mysql_real_escape_string() makes me laugh.

PHP is a mess.  However, you can write good PHP code.  It's just that you have to fight the language to do it.

There's really nothing unique about php, perl, or python.  They're all the same language with different semantics.  Pythonistas will object and say they're special snowflakes but honestly you can do a line-by-line or clause-by-clause transform between any of the languages.

I find perl to be the fastest to write in.  Python produces the prettiest code, though it is usually much longer than perl, particularly if you're doing anything text-related (e.g., re.compile, re.search, etc. vs perl's =~ operator).  

Perl tends to have no serious legacy problems because there's a bajillion modules and lots of the library is in the modules.  So if there's a problem with something clunky in a module, someone says "oh, don't use Old::Way, use New::Way instead".  This is nice because if you have a lot of code using Old::Way it still works, but everyone else can switch to New::Way.  New::Way users won't even have Old::Way code/bugs on their servers.  Of course this means that everyone has to install lots of modules to get things done.

Python puts everything "batteries included" and sometimes you end up with horrible stuff like urllib, ullib2, etc. (see python-requests.org instead).  Sure, the good news is that you get everything, but the bad news is that you get everything.  And in many cases you have to add other code anyway so this is a mixed blessings approach.  Fortunately the overall engineering is pretty good so in general you're glad to have everything, but if the python gods make mistakes, everyone suffers.

PHP has the python approach, though without the python quality of engineering.  It's like how the Chinese used to copy Russian planes, tanks, and rifles.  I mean, when was the last time you heard of something new being first implemented in PHP...

Now that I think of it...

Perl is like it was written by NASA.  Many subcontractors, lots of freedom to change, many ways to do things, very fast, refusing to tolerate the slightest inconvenience, lots of jokes in docs.

Python is like it was written by the Cosmodrome.  Central planning, big monolithic block, one way to do things, heavy dose of party dogma/idiom (even in docs!), everything written out to very long steps.  Still, the Russians do rockets very very well.

PHP is like it was written by a third world space agency.  Low quality standards, copies a lot of "big boy" ideas but does them poorly, half-assed implementation of big ideas, junky syntax.

I'm not sure where Ruby fits into this analogy.  But who uses Ruby anymore anyway?   :p
 
  • Like
Reactions: scv

dano

New Member
I have a book that I have used to refresh myself and read when I need to code in php:

http://www.amazon.com/PHP-Web-Visual-QuickStart-Edition/dp/0321733452

Then I will use the php manual to make sure I understand how that particular part works and review examples.

Otherwise, when I get stuck on a part that I wanna do, and need more of an example, I will usually go to YouTube and search for something that is related to it, and watch a few vids to get the concept in my head. 
 

Abdussamad

New Member
Umm.. sorry, but it kinda is.  I could likely fill several pages with problems I've come across with PHP (problems with the language itself, mind you);  but quite honestly so many people have done the same at this point that it's easier to reference existing lists.  Such as this one:  http://toykeeper.net/soapbox/php_problems/

3.3, 5.2, 10, 17, and 20 from that list are my pet peeves, and why I stick to Perl and Python when possible.
That list is long obsolete. We have namespaces, exceptions, anonymous functions, decent oop etc. now. Magic quotes is disabled by default.

I do agree that we could use some standardization as far as function names goes. Complaining about everything being built in without pointing out that that is actually one of the benefits of PHP is not right. It's great to have a ready to use function for every purpose and is one of the reasons behind PHP's success. The function names could be better and some of them could be rolled into one function but removing them entirely is not a good idea.
 

raindog308

vpsBoard Premium Member
Moderator
This alone demonstrates that PHP is not really professional grade:


No consistent naming convention is used. Some functions are verb_noun() and others are noun_verb(). Some are underscore_separated, while others are CamelCase or runtogether. Some are prefixed_byModuleName, and others use a module_suffix_scheme. Some use "to" and others use "2". And if you take a random set of ten library functions, chances are half a dozen different conventions will be included.

That's simply ridiculous and illustrates how slapdash and cheaply copied PHP is.

The sole reason behind PHP's success is right place/right time.  That's also the reasons for MySQL's success - it's hard to argue that MySQL is better than Postgres.  PHP had crude-but-workable web functionality at the right time.
 

Aldryic C'boas

The Pony
That list is long obsolete. We have namespaces, exceptions, anonymous functions, decent oop etc. now. Magic quotes is disabled by default.
..some of those flaws were present in early 5.x.  That's not long obsolete.. and let's be honest.  Even if PHP did have some miraculous overhaul since PHP4, that's taking WAY too long to correct very blatant problems.
 

Abdussamad

New Member
..some of those flaws were present in early 5.x.  That's not long obsolete.. and let's be honest.  Even if PHP did have some miraculous overhaul since PHP4, that's taking WAY too long to correct very blatant problems.
Early 5.x is long obsolete.  WP 3.2 made 5.2.4 mandatory. That was back in 2011. Also I think most hosts went directly from 4 to 5.2.4 when WP forced their hand.

I think you are misunderstanding how technologies succeed. It is rare that the best tech succeeds. Other factors are much more important. Take unix vs. windows, token ring vs. ethernet etc. as examples. In a lot of those examples the inferior tech that did succeed ends up adopting the features of the superior tech that failed to get the same traction. Like that whole sudo thing in windows 7.
 

Aldryic C'boas

The Pony
Early 5.x is long obsolete.  WP 3.2 made 5.2.4 mandatory. That was back in 2011. Also I think most hosts went directly from 4 to 5.2.4 when WP forced their hand.

I think you are misunderstanding how technologies succeed. It is rare that the best tech succeeds. Other factors are much more important. Take unix vs. windows, token ring vs. ethernet etc. as examples. In a lot of those examples the inferior tech that did succeed ends up adopting the features of the superior tech that failed to get the same traction. Like that whole sudo thing in windows 7.
Both paragraphs support my opinion rather than yours.  Early 5.x is long obsolete... k, so that just tells me it took even longer to fix glaring shortcomings and flaws.

I misunderstand nothing.  However, if you are trying to posit PHP is an efficient/better tech, than pointing out that inferior techs steal better ideas is not the way to do so.  Point is, PHP was an absolutely HORRID language for over a decade, and has made a snails pace at fixing its problems.  Is it better now?  Quite possibly.  Does it still contain a great deal of flaws?  Absolutely.

Side note:  I haven't use Windows for more than a couple hours at a time (or less) since Win95, so that reference just baffles me.  Sudo on Win7?  Wonderful, make it even easier for folks that should be restricted to an abacus to cause damage.
 

Adduc

New Member
Aldryic, I don't think Abdussamad is contending that PHP is the more efficient or better technology. It caught on because it could be integrated into HTML easier than most languages (had mod_python continued development, who knows what would have happened), and since then the developers have struggled trying to appeal to both amateur developers and career developers.

Yes, growth has been slow, but I think in some ways PHP suffered from the same thing Perl did. They wanted to go big with the PHP 6.0 release (I believe it ended up being 5.3), with core unicode support and namespaces, but weren't able to accomplish it in a timely manner. Since then, development has been focused on bringing PHP in line with other languages. PHP 5.4 shipped with a sizable performance increase as well as removing safe quotes, call time pass by reference, a built-in web server. 5.5 shipped with an opcode cache, a password API easy to maintain, generators, and deprecated the MySQL extension. 

I can acknowledge PHP has been slow to adapt, but I feel in the past few years real efforts have been made to change that. No, the function naming hasn't been fixed (rasmus seems dead set against it for now), but other critiques of the language have been addressed.

I'm obviously biased towards PHP because I work with it on a daily basis, but I really do think the language (and community) is trying to improve. Look to the PSR-FIG and Composer for examples of developers working to push the language forward.
 

Adduc

New Member
Double posting here, but this warrants noting:

w3schools is best way to learn php
w3schools is bad, out of date, and only serves as an example for individuals to use against PHP in citing examples.

No tutorial site should ever include examples that suffer from SQL injection (seen here).
 

Abdussamad

New Member
Aldryic, I don't think Abdussamad is contending that PHP is the more efficient or better technology. It caught on because it could be integrated into HTML easier than most languages (had mod_python continued development, who knows what would have happened), and since then the developers have struggled trying to appeal to both amateur developers and career developers.

Yes, growth has been slow, but I think in some ways PHP suffered from the same thing Perl did. They wanted to go big with the PHP 6.0 release (I believe it ended up being 5.3), with core unicode support and namespaces, but weren't able to accomplish it in a timely manner. Since then, development has been focused on bringing PHP in line with other languages. PHP 5.4 shipped with a sizable performance increase as well as removing safe quotes, call time pass by reference, a built-in web server. 5.5 shipped with an opcode cache, a password API easy to maintain, generators, and deprecated the MySQL extension. 

I can acknowledge PHP has been slow to adapt, but I feel in the past few years real efforts have been made to change that. No, the function naming hasn't been fixed (rasmus seems dead set against it for now), but other critiques of the language have been addressed.

I'm obviously biased towards PHP because I work with it on a daily basis, but I really do think the language (and community) is trying to improve. Look to the PSR-FIG and Composer for examples of developers working to push the language forward.
Yes this is what I meant. PHP is not the superior technology if you are a purist. But it is getting better.
 
Top
amuck-landowner