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?
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.
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 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
Originally Posted by Dereksdontrun
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.
Originally Posted by Dereksdontrun
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.]
PHP isn't primarily an object-oriented language; it's a language that supports OO design (without being limited to it).
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.
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).
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 he’s a better programmer now!" ~ http://www.oreillynet.com/ruby/blog/...ck_to_p_1.html
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
Bookmarks