1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

PHP education?

Discussion in 'PHP' started by modz, Dec 15, 2011.

  1. #1
    I know a guy who has been studying PHP and MySQL for 2 months. He also has some basic HTML and CSS knowledge. Yesterday he told me that a week ago he made a shopping cart on his own but without using OOP - just functions, variables and arrays. He knows how to create a class and an object, what is a method, what does __construct() do and so on, but he doesn't know when to use OOP instead of functions, variables and arrays. He asked me about this, because I have some PHP experience. I told him what I thought, but I think my answer was pretty subjective, so I ask you for help. What would you tell him? He also asked me if I can give him a few ideas what script to create in order to learn the good OOP practices. I told him some stuff like login system, product manager and I also suggested him to buy a book with C/C++ exercises since most of them are doable with PHP and this book has to contain OOP exercises (otherwise it is poor). What do you recommend?
    SEMrush
     
    modz, Dec 15, 2011 IP
    SEMrush
  2. codecre8r

    codecre8r Well-Known Member

    Messages:
    148
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    128
    #2
    I think he would really need to understand how OOP actually works before trying to implement it while learning. It can get a little complicated if you don't understand the underlying functionality.

    The product manager example would be a good one to start with, IMHO. Show him how to create an object that manages the database and logic operations for products, and I think he would get the hang of it pretty quickly.
     
    codecre8r, Dec 15, 2011 IP
  3. modz

    modz Active Member

    Messages:
    95
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    53
    #3
    Thanks for the answer.
    He is now reading the 'Classes and objects' part of the PHP's manual and trying to get the point of OOP. I think he will, because he is always searching for the logic behind the theories (he likes complicated math) :) Then, if he didn't find out, I will show him how to make DB queries using OOP and then he is ready to begin to make little projects using OOP.
     
    modz, Dec 15, 2011 IP
  4. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #4
    Use a class if the code is going to be reused (say, sending emails from the site). If it's code that will only be used once, don't bother with a class.

    If you have simple database code I wouldn't bother writing a class to handle it. If you're doing the same thing over and over it may pay, or just a few functions may be more efficient. Two months is hardly enough time to learn what type of code might be better handled by a class - that's something that comes with experience.
     
    Rukbat, Dec 15, 2011 IP
  5. sarahk

    sarahk iTamer Staff

    Messages:
    26,446
    Likes Received:
    3,958
    Best Answers:
    111
    Trophy Points:
    665
    #5
    Experience will give him a greater understanding - by the time he's worked on a few different systems and seen classes used well and badly. When I first learnt OOP I went a bit nuts and used them where a simple script would have done the job. OK in many ways - just overkill really.
     
    sarahk, Dec 15, 2011 IP
  6. webmaster4321

    webmaster4321 Peon

    Messages:
    36
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6

    I agree with this approach
     
    webmaster4321, Dec 19, 2011 IP
  7. Rainulf

    Rainulf Active Member

    Messages:
    373
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    85
    #7
    It's actually possible to write a decent web application without the use of OOP - be it a clone of Facebook, Google, etc.

    You sound like you can't reuse a function. ;)

    The point of OOP is to get a clear visualization of what you're coding, hence object oriented - you see codes as "objects"
     
    Rainulf, Dec 20, 2011 IP
  8. rajmeetbhullar

    rajmeetbhullar Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I must say you should start working on core php with basic knowledge of programming. yet functions are an advantage , if you are good in programming . So if you need to take help use official site of php or w3schools where you will get a lot of help
     
    rajmeetbhullar, Dec 21, 2011 IP
  9. cogzidel

    cogzidel Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    cogzidel, Dec 23, 2011 IP
  10. SOLOWPOET

    SOLOWPOET Active Member

    Messages:
    197
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #10
    Wow I've only read these few Post and I need a aspirin(lol) to me you Guy's sound like Charlie Browns Teacher..Don't Understand a word you all are saying..Wah Wah wah....wah wah
     
    SOLOWPOET, Dec 23, 2011 IP