Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Learning PHP OOP: where to start?

Junior Spellweaver
Joined
Aug 15, 2011
Messages
167
Reaction score
15
Hello RageZone,

I want to start coding in PHP in an OO way. But I really don't have an idea where to start. What to learn first and how to use everything.

DO you guys have some tips, speaking from your own experiences? How did you learn it, what did you use for it or perhaps what place (a site, for instance).

Many thanks in advance.

- Galago
 
Joined
Dec 15, 2009
Messages
1,387
Reaction score
236
This is how i learnt.
http://forum.ragezone.com/f690/addons-feature-character-display-script-1041661/

It really seems tough and confusing at first. But, once you're used to it, you can finally code really nice, clean and fine procedural codes.

Start up your own project, for example creating a GD image generator. Like I did.

Galago - Learning PHP OOP: where to start? - RaGEZONE Forums
 
Skilled Illusionist
Joined
Sep 22, 2012
Messages
300
Reaction score
65
PHP docs and general stuff on OOP

< - C# oriented but it could be useful

PHP Docs is a bit too boring for me :/
I learnt from thenewboston. It's recently updated and has a new UI.
 
Joined
Dec 15, 2009
Messages
1,387
Reaction score
236
PHP Docs is a bit too boring for me :/
I learnt from thenewboston. It's recently updated and has a new UI.

they may be boring, but they are really useful and well described in terms of functionality.
i never came across with any silly teaching sites, mainly because i'm lazy, plus i rather learn from my own and gain experience.
 
Skilled Illusionist
Joined
Sep 22, 2012
Messages
300
Reaction score
65
they may be boring, but they are really useful and well described in terms of functionality.
i never came across with any silly teaching sites, mainly because i'm lazy, plus i rather learn from my own and gain experience.

Entirely agree. People just have different methods of learning. I combined a little bit of both though. I used the teaching sites and other people's projects to learn OOP. Galago I would recommend that you take a look at a variety of resources and then just choose whatever floats your boat.
 
Junior Spellweaver
Joined
Aug 15, 2011
Messages
167
Reaction score
15
PHP Docs is a bit too boring for me :/
I learnt from thenewboston. It's recently updated and has a new UI.
I used to watch tutorials on TheNewBoston, but forgot about the name. I'm going to use that.

And thanks all! I am going to try a few sites you guys said to me.
 
Joined
Jun 8, 2007
Messages
1,985
Reaction score
490
I think the best way to learn is to find a mentor. Somebody you can look up to whom can answer questions and give you direction. By posting here, that is essentially the path you've already taken. You don't necessarily need 1-on-1 coaching (a forum is n-on-1), but tutorials and documentation on the internet is a 1-way communication- the web-sites give you information. You can ask google questions and it will give you answers, but having a real person to talk to is probably the best way to learn. Google will not tell you what mistakes you're making, or whether a given tutorial is out-of-date or using the latest techniques for the latest, cutting-edge version of PHP. Some tutorials are even teaching not only out-of-date information, but bad practices. Having a real guru you can call to show off what you're doing or ask questions- or even get you out of sticky situations- is a huge advantage.
 
◝(⁰▿⁰)◜Smile◝ (⁰▿⁰)◜
Developer
Joined
May 29, 2007
Messages
2,167
Reaction score
899
 
Newbie Spellweaver
Joined
May 20, 2014
Messages
43
Reaction score
10
Here's my little intro to OOP.

If I have any suggestions to you, it is to use the PHP docs as said above:

But before you get into documentation and examples, you should know exactly what the difference is between OOP and Procedural PHP, and some general knowledge on objects, classes, and functions.

OOP is a great way to practice DRY (Don't Repeat Yourself). It also helps immensely with keeping your code clean, modular, and easy to maintain.

Objects, Classes, and Functions.

Code:
<?php

class foo {

    public $var = "";

    function bindParam($param) {called.

        $this->var = "Hello World!" . " " . $param;
        
        return $this->var;

    }

}

$bar = new foo;

$myString = $bar->bindParam("My first OOP script!");

$myOtherString = $bar->bindParam("My second OOP script");

echo $myString . "<br />";

echo $myOtherString;

?>

So here we have a class called foo, with a function that adds a parameter onto the end of a preset string.

What I'm trying to show here is that you can use the same code (function bindParam) multiple times, for different objects. (I.E. $myString and $myOtherString)
 
Junior Spellweaver
Joined
Aug 15, 2011
Messages
167
Reaction score
15
Thanks you all for your help!! I found a mentor, like s-p-n said. And I am watching tutorials on YouTube from Codeacademy. It isn't really hard to understand I am learning very fast (although I am the one who says that. :p).
 
Newbie Spellweaver
Joined
Aug 30, 2013
Messages
25
Reaction score
9
Well if you already know PHP - i think the main part about learning Object Oriented Programming is the mindset. You are hiding a lot of functions and code in a abstract object, from there its much simpler to see the bigger picture because instead of 10 lines here and there doing one goal, you have two or four lines of code, you can then also see what is going on before and after since you can fit it all on your screen.

A good mentor can point you in the right direction, but actually playing with your own projects and making mistakes is when you learn the most.
 
Back
Top