Right Time to Start learning OOP in PHP..?

Beginner Learner here…!

[COLOR=“#000000”]Though m from a technical background but not towards Programming, I have been sincerely studying, understanding and applying the basics (Arrays, Loops, Conditions, functions,etc) of PHP though referring PHP 5.3 Book (+php programming classes) for almost a month (3/hr a day). Now, when i feels that i got a strong foundation on basics of PHP, then comes the Procedure to apply those…

The Book from which i was referring apply both Procedural and Object Orient Programming code…and its really killing me …to grasp both at the same time.:nono:.!!

So, here my Question for fellow PHP developers…what should i do… Learn both or Choose One…?? Since OOP is now considered as standard procedure in most of app development… Does mastering the Procedural Programming code is necessary to learn OOP… ?

I likes Procedural Programming, coz its makes easy flow of logical ( but OOP looks like distribution of logic in parts of Classes, objects n methods…)
[/COLOR]
Note: Average in HTML and CSS only.

Your book will probably have to skim over the higher principles of OOP, and to fully grasp them in order that you get the maximum benefits that OOP offers you will buy many more books (unless you are a secret Will Hunting).

Certainly learn the syntax of OOP in PHP 5.3 if you are in learning mode.

You can start using PHP to write scripts without using OOP, but can gradually add it in order to “simplify” or shorten your scripts.

I think the easy wins in adopting OOP in PHP are encapsulation and complexity hiding, grab these low hanging fruit.

Make sure you fully adopt PDO if you can because this forces you to use objects, and PDO is an ideal base class to start hiding things and including them as and when you need them.

You will see threads on here about building on PDO too.

You have to absolutely nail the syntax and best use of functions though before even thinking of their equivalent in OOP (methods). If you are extracting complexity and repetitive code as functions, and putting them in their own files and including them as a matter of course as you work (note: not as you learn) then you will switch to OOP with far greater ease, and it should make much more sense to you.

Thank you so much for taking such effort and time for the explanation (To Learner’s)… Actually the dilemma (of OOP and Procedural) started when i encounter on the book on the section of “Retrieving Data from Mysql with PHP” when the author starts using PDO techniques to connect database…and while checking on some other books the techniques where totally different…!!!..
Though i can understand both the procedure…but .mastering the ONE is wat i matters…!!.. So, One More doubt, Which Book to Follow now.???..One with PDO or one with procedural one…
Its sounds Stupid… but i really need to know…Thanks…

If you have a book which is using PDO as is example, then it must be quite a modern book, and I would say stick with that.

You will find books using the deprecated mysql_<anything here> functions, I would not spend much time learning that syntax.

You will find books using mysqli for which you can use either procedurally or in an OOP fashion. That is likely to be a newish book too.

I am a proponent of PDO, but there are similarly proponents of Mysqli, they are remarkably similar - take a read of this recent post if you want a better understanding.

Understanding PDO and PDOStatement can be quite an uphill struggle, so come back with specific questions when you get stuck, though you will have to be prepared to post code explaining your situation sometimes. Just xxxx out the database credentials prior to posting if you have to include them.