Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End How did you learn PHP?

  • This topic is empty.
Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #176868
    Anonymous
    Inactive

    PHP has got to be the most difficult language i’ve ever tried to learn. Not because it has confusing syntax, or it’s too difficult. It’s because of the lack of decent documentation, and tutorials. learning jQuery was extremely easy, and even pure javascript is really easy for me to learn despite the fact i haven’t even tried to learn it, only recently. I’m being really careful with PHP because its a dangerous language if you don’t know it properly. I learned some languages from W3Schools.com but always realized their documentation is horrible and outdated when i got really good with the language, so theres no way i’m learning PHP from w3schools. I sometimes watch youtube videos but even i can see their using outdated methods like mysql_connect(even the recent videos). PHP.net has ok documentation but its like they assume you know C or some other advanced language. So i want to know how you learned PHP.

    #176869
    nixnerd
    Participant

    Great question for @traq or @chrisburton. I personally HATE PHP. I “learned it” if you can even say that by messing around with WordPress. However… that’s precisely the problem. A lot of people come to PHP through WordPress. Therefore, they are in now way qualified to put out “real” tuts on PHP, because their knowledge is confined to a specific eco-system.

    For me… it’s the syntax and the way the language looks. I need my code to look at least somewhat sexy and PHP does not have the sex appeal. Beyond that, it does nothing that other languages can’t… so it’s not like I really NEED it.

    I use it for simple includes… and that’s about it.

    On another note… try Python. I think Traq can attest to the fact that it’s really clean and fun. However… some of the web friendly frameworks like Django apparently have a fairly large learning curve.

    If you like JS… learn Node. Then, you can just write JS all through your dev stack!

    #176870
    nixnerd
    Participant

    I personally feel that the language feels “bolted together.” It’s no secret a lot of PHP haters love to bring up the fact that it was never designed to do things like OOP. While this is true, that’s no reason to hate it. But… poor design that feels clunky is. I just never had fun writing it… much like you it sounds like :)

    #176874
    __
    Participant

    It’s because of the lack of decent documentation, and tutorials.

    Unfortunately, you’ve hit the nail on the head. PHP is largely a chronic beginner’s language for just this reason.

    php.net is your best, most reliable source. It is indispensable; but it is also less a tutorial than a reference manual. (and don’t put too much stock in the comment sections.)

    Almost anything else you find should be taken with a big grain of salt until you get to a level of semi-proficiency where you can start to distinguish between good|crap.

    One good thing I was introduced to recently is PHP the Right Way. I wish this had been around when I was learning.

    I personally feel that the language feels “bolted together.”

    Certainly was. PHP was not “designed” in any real sense of the word… it was basically thrown together as a highly task-specific scripting syntax and web utility for C. Over the years, it has not so much “evolved” as had more stuff “tacked on” to it. Good stuff coexists with bad in the name of backwards-compatibility. Object Oriented Programming is now a very real capability (PHP even has closures now …of a sort). While it is now a very nice, powerful language, when used carefully, there is admittedly still much sadness.

    How did you learn PHP?

    I started the hard way (not the “good” hard way): trial and error with no real instruction or reference. Finding php.net was instrumental in getting better. My understanding of OOP in PHP “clicked” once I learned more about OOP in javascript (but no, they aren’t similar: it was more of an understanding-by-contrast). Other than this, lots of practice, asking questions, and reading other people’s code.

    Where are you at in your learning? do you understand the syntax, variable types, scope? how to use functions? how to use objects? what other programming languages do you know, and how well do you know them?

    Couple things off the top of my head:

    • use recent PHP versions. 5.2.x and lower are unsupported, have serious unfixed problems, and should never be used. 5.3 isn’t really that great either.
    • never trust your users. this is a programming-in-general rule, but is particularly overlooked by PHP coders. validate everything that comes in; sanitize everything that goes out.
    • use unicode (UTF-8) (everywhere).
    • indent your code. use comments if something is remotely not obvious. do not use abbreviations.
    • never use == (or !=); always use === (or !==).
    • always use {braces} (even though they are “optional” for single-line ifs, etc).
    • never use @. by extension, never ignore errors: search them out, make them impossible to ignore, and then fix them. (while the @ operator actually does have legitimate uses, most coders will never encounter these cases and instead treat it as a magical error correction operator.)
    #176875
    __
    Participant

    and yes, Python and Node are fun too.
    But despite all of PHP’s faults, I still love it. I do a lot of work with it, and am still willing to invest a lot into it. Done right, it’s hard to beat.

    #176880
    chrisburton
    Participant

    never use == (or !=); always use === (or !==). – @traq

    Why is that (curious)? Is this the answer?

    #176958
    __
    Participant

    Is this the answer?

    Yes. (Same holds true for javascript.) There are edge cases where you actually want type coercion, but you usually don’t:

    if( strpos( "string","s"  ) == false ){
        echo "The letter 's' is NOT in the word 'string'";
    }
    

    Because s is at position 0, and 0 == false, this will claim that “The letter ‘s’ is NOT in the word ‘string’,” whereas using 0 === false would give the correct result.

    Most coders don’t understand the difference between == and ===, or all of the quirks surrounding them, so it’s best to just stick with === by default.

    #176979
    chrisburton
    Participant

    @traq Thanks for that explanation.


    @Joe_Temp
    @Jarolin

    PHP is just what I started learning because of the WordPress hype when I first started out. But in reality, I wasn’t truly learning, I was memorizing things. Only until I started building my own stuff did I learn. PHP is still quite new to me, I’m nowhere near @traq’s level. I started watching these Harvard lectures on Youtube that helped me learn and comprehend sessions and a few other things about security which was related to my project. I’m not really familiar with Python so I can’t really speak about it but I’m sure there are advantages/disadvantages to each. I’m going to take a look at that “PHP The Right Way” link. Might help a great deal.

    Anyway, I recently started researching HHVM and I hope to use it soon.

    #176987
    nixnerd
    Participant

    I remember you talking about HHVM… please keep us posted on what you think about that.

    #177020
    Anonymous
    Inactive

    Thanks guys. I know for a fact PHP will become easier to learn once i know the basics and how the syntax works.

    #177069
    __
    Participant

    Yeah… the “basics.” : )


    digraph: PHP comparison operators

    #177070
    nixnerd
    Participant
    #177257
    chrisburton
    Participant

    Saw that on Facebook. Progress!

Viewing 13 posts - 1 through 13 (of 13 total)
  • The forum ‘Back End’ is closed to new topics and replies.