resources for learning up to date php for beginners?
Results 1 to 8 of 8

Thread: resources for learning up to date php for beginners?

  1. #1
    Junior Member
    Join Date
    Mar 2012
    Posts
    24

    resources for learning up to date php for beginners?

    Hi,
    I've been teaching myself php, but have come to realise that the php I have been learning from books and tutorials online is not as up to date as it should be.Even brand new php books are teaching about MySQLi rather than PDO and whats with all the -> . what does that mean??
    What resources are available that i can be assured are current and easy for a beginner to understand?

    cheers

  2. #2
    Senior Member traq's Avatar
    Join Date
    Jun 2011
    Location
    so.Cal
    Posts
    949
    mysqli ("i" for "improved") is not outdated - it's the old mysql extension that should be avoided.

    the -> operator is used for accessing properties and methods of objects:
    PHP Code:
    class someObject{

        public 
    $property "some value";

        public function 
    myMethod(){
            return 
    "Hello!";
        }

    }

    $obj = new someObject();
    print 
    $obj->property;     // prints "some value"
    print $obj->myMethod();   // prints "Hello!" 
    As far as tutorials go, I don't really know any good current ones. Check out the ones offered on php.net, which is also the best language reference available.

  3. #3
    Junior Member
    Join Date
    Mar 2012
    Posts
    24
    Thanks for clarifying that Traq...would i be correct in thinking that -> is object oriented php and that i have been learning procedural php, hence my unfamiliarity with it?

    I try to read stuff about OOP, classes, methods and objects but lose the will to live shortly afterwards.

    Is it acceptable practice to code using a procedural style, if i am happy to do so? will i be seen as a 'lesser' coder?

    Likewise if i mix my html and php and dont use MVC. Im not a professional coder but it works so should I be more relaxed in my approach rather than confuse myself with trying to learn best practice?

    thanks for your time

  4. #4
    Senior Member traq's Avatar
    Join Date
    Jun 2011
    Location
    so.Cal
    Posts
    949
    Quote Originally Posted by Dereksdontrun View Post
    Thanks for clarifying that Traq...would i be correct in thinking that -> is object oriented php and that i have been learning procedural php, hence my unfamiliarity with it?
    yes, Object-Oriented.
    I don't know what "kind" of PHP you've been learning

    Quote Originally Posted by Dereksdontrun View Post
    I try to read stuff about OOP, classes, methods and objects but lose the will to live shortly afterwards.
    Is it acceptable practice to code using a procedural style, if i am happy to do so? will i be seen as a 'lesser' coder?
    perfectly acceptable.
    I wouldn't be afraid of OOP, however. Very useful. mysqli is object-oriented (the mysqli_*() functions only alias the object methods), so you have an opportunity for plenty of practice. Likewise, if you use much javascript (especially a library, like jQuery), you've probably been using OOP without realizing it.

    Quote Originally Posted by Dereksdontrun View Post
    Likewise if i mix my html and php and dont use MVC. Im not a professional coder but it works so should I be more relaxed in my approach rather than confuse myself with trying to learn best practice?
    I'd recommend not avoiding best practices. (They're called "Best" for a reason, after all.)
    (However, as noted above, that doesn't mean that you have to be Object-Oriented.)

    I'd highly recommend not mixing HTML and PHP.
    It can cause problems that are hard to track, limit your error handling (& recovery), and just generally has a tendency to get "messy." I strive to do all of my PHP logic/processing first, and all output last. [an example.]

  5. #5
    Pedantic Curmudgeon Weedpacket's Avatar
    Join Date
    Aug 2002
    Location
    General Systems Vehicle "Thrilled To Be Here"
    Posts
    21,885
    PHP isn't primarily an object-oriented language; it's a language that supports OO design (without being limited to it).

    Quote Originally Posted by traq
    Likewise, if you use much javascript (especially a library, like jQuery), you've probably been using OOP without realizing it.
    Though at risk of muddying the waters, I'd have to point out that JavaScript uses a completely different approach to OO from the one PHP uses.

    As far as authoritative reference material goes, The Manual is your best friend. Whatever tutorials you come across, cross-check what they say with what is said in the manual. You can also start with the tutorials and FAQs there, and skip around in some of the other sections to get a picture of what's going on.
    THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER
    FAQs! FAQs! FAQs! Most forums have them!
    Search - Debugging 101 - Collected Solutions - General Guidelines - Getting help at all

  6. #6
    Senior Member
    Join Date
    Mar 2009
    Posts
    812
    Quote Originally Posted by traq View Post
    I'd highly recommend not mixing HTML and PHP.
    It can cause problems that are hard to track, limit your error handling (& recovery), and just generally has a tendency to get "messy." I strive to do all of my PHP logic/processing first, and all output last. [an example.]
    While I strive to do as much PHP before my HTML as possible, mixing the two is nearly unavoidable. You can do it safely and cleanly you just have to create a set of rules and standards for yourself and stick to them. Also having a good editor/IDE helps, too.

    I also try to avoid echoing out as much HTML as I can because you lose your editor's benefits such as syntax highlighting, auto complete, tooltips, etc. plus it can be difficult to read markup as a PHP string on multiple lines (or even on the same line since HTML really is meant/looks better on "cascading" lines).
    Declare variables, not war.

  7. #7
    High Energy Magic Dept. NogDog's Avatar
    Join Date
    Aug 2006
    Location
    Ankh-Morpork
    Posts
    13,943
    Most people who do not start out learning an object-oriented language tend to suffer from some "inertia" of sorts to make the switch to OOP (yours truly, included). Once you've worked at it enough, eventually something clicks in your mind, and suddenly you "get it" and want to use it all the time. For me, probably the main catalyst (besides time) was Matt Zandstra's book, PHP 5 Objects, Patterns, and Practice. It helped make things gel in my mind as to the "why" of object-oriented PHP, not just the "how".
    Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be." ~ from Nation, by Terry Pratchett

    "But the main reason that any programmer learning any new language thinks the new language is SO much better than the old one is because hes a better programmer now!" ~ http://www.oreillynet.com/ruby/blog/...ck_to_p_1.html


    eBookworm.us

  8. #8
    Senior Member Derokorian's Avatar
    Join Date
    Apr 2011
    Location
    Denver
    Posts
    1,784
    Quote Originally Posted by NogDog View Post
    For me, probably the main catalyst (besides time) was Matt Zandstra's book, PHP 5 Objects, Patterns, and Practice. It helped make things gel in my mind as to the "why" of object-oriented PHP, not just the "how".
    +1 for PHP 5 Objects, Patterns, and Practice
    Sadly, nobody codes for anyone on this forum. People taste your dishes and tell you what is missing, but they don't cook for you. ~anoopmail
    I'd rather be a comma, then a full stop.
    User Authentication in PHP with MySQLi - Don't forget to mark threads resolved - MySQL(i) warning

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •