Forums

Give help. Get help.

  • # 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 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 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 4:06 pm

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

    __
    # 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';
        }
    }
    
    # August 11, 2014 at 10:00 pm

    So a class is basically describing the purpose?

    By the way, I just started reading that thing and so far it’s great.

    # August 11, 2014 at 10:15 pm

    See this answer at SO.
    http://stackoverflow.com/a/2206835

    # August 11, 2014 at 10:34 pm

    @AlenAbdula Awesome analogy to explain classes! Totally makes sense.

    __
    # August 11, 2014 at 11:39 pm

    We had a private conversation in which he relayed to make my own experiences rather than listen to what other people object to.

    Well, yes, but things are also designed and built with specific purposes in mind. Using a class as a “name” wrapper for a bunch of loosely-related methods might work —in the sense that it accomplishes that goal and doesn’t really break anything in doing so— but there is no advantage in using a class this way.

Viewing 15 posts - 1 through 15 (of 28 total)

You must be logged in to reply to this topic.

icon-anchoricon-closeicon-emailicon-linkicon-logo-staricon-menuicon-nav-guideicon-searchicon-staricon-tag