Grow your CSS skills. Land your dream job.

PHP education

  • # August 10, 2014 at 10:56 pm

    I’m trying to learn more about PHP and I’m at the point where it seems I’m not really getting anywhere. I feel like I’m learning the wrong way (using Kirby which I have been instructed to “throw it as far overboard as possible”).

    What kind of projects should I build that would be efficient to learn? Some have recommended that I create a minimalist project.

    Should I jump into OO PHP, templating? Sorry if I’m not making sense. Some have also recommended the PHP docs but I’ve never been able to learn through there. I’ve only used it as a resource to double check global variables or see if I’m doing something correctly. I’d prefer to learn from a resource similar to how MDN does it for html in which it basically tells you when to use certain elements. I’m not sure if that really applies to how PHP works or if there are such resources.

    On the Stack Overflow chat, one person recommend this project but if you view the solution for PHP, I’m not even at that level to create functions, etc.

    # August 11, 2014 at 2:11 am

    I’m not even at that level to create functions, etc.

    Now you know what you want to learn next :).

    I’ve read through the list and the ‘numbers’, ‘Classic Algorithms’, ‘Security’ and possibly ‘Text’ seem perfect excercises for an advanced beginner. Some might be a little too difficult though.
    Dont let yourself get feared off by the complexity of the solution, there are multiple ways of achieving these things.

    Based on your post however, I have no idea about your actual skill level.

    # August 11, 2014 at 3:12 am

    Thanks for responding!

    Now you know what you want to learn next :).

    But I’m trying to find a resource that displays educational information similar to the MDN link where it describes where and when it should be used. I’ve never found PHP tutorials similar to this.

    I’ve read through the list and the ‘numbers’, ‘Classic Algorithms’, ‘Security’ and possibly ‘Text’ seem perfect excercises for an advanced beginner.

    I quickly glanced at the first exercise and I’m pretty confident that I can accomplish that.

    # August 11, 2014 at 4:49 am

    If you can accomplish all of those excercises you’re on the right track, and you should be looking to get some experience with big projects. Develop your own dynamic website, or join a website’s devteam. You got the basics behind PHP programming, but it’s time you learn to write code within certain code formatting guidelines.

    Object-oriented programming is quite useful to pick up, although it is quite messy to start with in PHP. I suggest you learn Java to gain a grasp of object orientated languages (as a bonus, you’ll also learn those functions you’re dreading). It’s never a bad idea to learn multiple programming languages, even if you’re never going to use some of them.

    The reason you dont find ‘when to use what’ articles for PHP, is because there is no set guideline. In HTML there is (if you write your code the semantic way). But for PHP there are plenty of ways to achieve the desired results, and none of them is simply the ‘best’. (You could look at performance, but that’s quite advanced and far from as straightforward as HTML is). I’m afraid the only guideline is personal experience.

    About a specific project: there’s a person trying to set up his own site/forum kind of thing on this forum, maybe you could do the same thing, or even join and help him?

    __
    # August 11, 2014 at 12:30 pm

    Kirby which I have been instructed to “throw it as far overboard as possible”

    Out of curiosity, why? I’ll admit that it’s not the best stuff I’ve seen (especially the older version), but nothing really struck me as “wrong.” I haven’t used/ investigated it in depth, though.

    I’m not even at that level to create functions, etc.

    If you’re not comfortable with them, functions are definitely the next thing to learn. You have a task: put arguments in, return a result.

    I’ll second learning object-oriented programming. I don’t like java, though (personal preference). While javascript and php have different rules, js is pretty good at teaching you how to think in object-oriented terms.

    About a specific project…

    I would recommend against tying yourself to someone else’s project. You’d be limiting yourself not only to their approach and abilities, but to the specific goals of the project (including delivery: i.e., if you discover a need to scrap what you’ve built and start over, you don’t want a lot of pressure not to).

    If you want to learn about OOP, maybe you could start by making objects to handle the HTTP Request and Response. Easy to model, think up methods for, useful for future projects. And a response object could lead to a way to handle templates.

    # August 11, 2014 at 12:57 pm

    http://www.laracasts.com nuff said!!! while Laravel specific, you’ll learn so much about OOP, design patterns, architecture, etc.

    Here’s the list of lessons: https://laracasts.com/all

    # August 11, 2014 at 2:06 pm

    About a specific project: there’s a person trying to set up his own site/forum kind of thing on this forum, maybe you could do the same thing, or even join and help him? – @Soronbe

    I have been following that thread since it began but I just don’t have the time to be involved in a project where someone might be counting on me. My schedule is soon to get whacky now that school is about to begin.

    Out of curiosity, why? I’ll admit that it’s not the best stuff I’ve seen (especially the older version), but nothing really struck me as “wrong.” I haven’t used/ investigated it in depth, though. – @traq

    Apparently because it “uses static calls everywhere” and that is generally bad practice according to the person I spoke to on the PHP chat over at Stack Overflow. He also suggested that I not begin learning templating at this stage as it might be a little difficult if I don’t know basic functions and classes.

    I’ll second learning object-oriented programming. I don’t like java, though (personal preference). While javascript and php have different rules, js is pretty good at teaching you how to think in object-oriented terms. – @traq

    Is it fundamental that I choose a different language just to grasp OOP in PHP? It’s not that I don’t comprehend OOP because I don’t think I’ve ever really took the time to read up on it.

    I would recommend against tying yourself to someone else’s project. You’d be limiting yourself not only to their approach and abilities, but to the specific goals of the project (including delivery: i.e., if you discover a need to scrap what you’ve built and start over, you don’t want a lot of pressure not to). – @traq

    Exactly! I wish I had time to contribute to the project suggested above. I really do. But my schedule would not allow me to and I wouldn’t want to disappoint or frustrate someone because of that.

    http://www.laracasts.com nuff said!!! – @AlenAbdula

    Thanks, Alen!

    # August 11, 2014 at 2:30 pm

    By the way, I think what confuses me in regards to functions is the whole public/private thing. When to use or leave them out. I should have mentioned that above.

    # August 11, 2014 at 2:47 pm

    @chrisburton email me at alenabdula [at] gmail [.] com I’ll send you some material related to OOP/PHP.

    # August 11, 2014 at 3:47 pm

    Is it fundamental that I choose a different language just to grasp OOP in PHP? It’s not that I don’t comprehend OOP because I don’t think I’ve ever really took the time to read up on it.

    Not strictly necessary, but I must say OOP in PHP is quite mal-written and if you only ever used it in PHP, you’ll never fully understand it.

    Javascript does this a lot better but it is dynamically typed, and in my opinion the true beauty of OOP lies in static typed languages like Java. You’ll also gain a much more deep understanding of what OOP actually is and realise it’s potential!
    OOP is notoriously hard to pick up on your own, ask someone in your environment to help you, or arrange some chat sessions with someone that has a (decent/deep) understanding of it. If you’re not used to static typed languages, that will be even harder but it is very much worth the effort.

    Few quick points:
    PHP OOP is very sloppy, and you shouldn’t start with this.
    If you dont want to learn Java, learn Javascript (if you’re serious about learning PHP for web development you’re bound to use javascript in future anyway). The big issue here is that an object strictly has no methods, it has variables (attributes) that happen to have a function stored in them.
    Java has the potential to give you a deep understanding of OOP and it’s beauty, but it’s difficult to pick up (gets easier once you’ve mastered the basics) and chances are you’ll never use it again. (even though java is one of the most used languages of the moment).

    NOTE: most of this is ofcourse personal opinion, but there are some points in here that are hard to argue about.

    By the way, I think what confuses me in regards to functions is the whole public/private thing. When to use or leave them out. I should have mentioned that above.

    Public means your method can be accessed anywhere, private means your method can only be called from another function in your class/object. Protected means the method can be called from it’s own class and that class’ children in the inheritance-tree.

    # August 11, 2014 at 4:06 pm

    OOP/PHP used to be a hack. It has come a long way since then.

    # August 11, 2014 at 4:29 pm

    Agreed, but I still think OOP/Java is superior by far and especially for learning. I am not saying OOP/PHP is terrible, but it is far from the ideal first OOP language. A lot of people that were taught OOP solely by PHP seem to think a class is merely a container for methods and (if lucky) some attributes.

    __
    # August 11, 2014 at 6:01 pm

    Is it fundamental that I choose a different language just to grasp OOP in PHP?

    No, not really. I wish I had a good resource for you… I had an “ah-ha!” moment with OOP, but I’m not sure I could point out specifically what led to it.

    I think what confuses me in regards to functions is the whole public/private thing.

    Functions don’t have public/private; that’s objects.

    As for when to use public vs. private, it all comes down to how the property/method is used. Public methods are those that you intend to use in your code; private methods are only meant to be used internally by the object itself.

    Don’t worry too much about it in the short term. It is an important concept, but you won’t “ruin” things by making everything public to start and going back to it later, once you understand what’s going on more clearly.

    I am not saying OOP/PHP is terrible, but it is far from the ideal first OOP language. A lot of people that were taught OOP solely by PHP seem to think a class is merely a container for methods and (if lucky) some attributes.

    Well, I’d argue that that —like most of the language— is an issue of how people use it, not how it actually works.

    [Kirby] “uses static calls everywhere” and that is generally bad practice

    Ah. Yeah, in places he’s just treating objects as a way of “namespacing” (grouping) functions together. As Soronbe pointed out, that’s not really what OOP is for. An object represents a specific thing, and its methods represent what it can do/ what you can do to it.

    # August 11, 2014 at 8:42 pm

    Functions don’t have public/private; that’s objects.

    Ok. Perhaps that’s where my confusion is, in regards to functions since I see a lot of code that looks like this:

    public function something() {
        ....
    }
    

    I think I’m just over-complicating it.

    Ah. Yeah, in places he’s just treating objects as a way of “namespacing” (grouping) functions together. As Soronbe pointed out, that’s not really what OOP is for. An object represents a specific thing, and its methods represent what it can do/ what you can do to it.

    We had a private conversation in which he relayed to make my own experiences rather than listen to what other people object to. Which is absolutely great advice but when it comes to programming or development in general, even though there are multiple ways to build the same thing, there is also room to go about it the wrong way, specifically on how the language was designed to do certain things. I hope that makes sense.

    # August 11, 2014 at 9:52 pm

    Following will result in syntax error.

    
    // Function
    public function sayHi() {
        echo 'Hi';
    }
    

    In context of a class, a function is called a method.

    
    class Car implements DriveableInterface {
        // Method
        public function isDriveable()
        {
            return 'Car is Driveable';
        }
    }
    
Viewing 15 posts - 1 through 15 (of 39 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".