SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    John 8:24 JREAM's Avatar
    Join Date
    Sep 2007
    Location
    Florida
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Why is PHP not OOP?

    What do they mean that PHP is not a OOP language?
    In any OOP language like Java, is it possible to do procedural coding?

    I don't understand what makes PHP not OOP, is it a lack of certain features that other OOP languages have? What are a few of them if that is the case?

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2008
    Posts
    1,149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In Java, everything other than primitive data types are objects. There's no procedural code.

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,862
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    PHP (like C++) supports both procedural and OOP programming so you are not forced to use OOP at all. You have a choice of two of the several different programming styles that you can use with the language rather than just the one that most languages offer.

    I'd disagree with any statement saying that PHP isn't an OOP language because it can be used as an OOP language. Saying that PHP isn't object-oriented is no more true than saying it isn't procedure-oriented, Saying that it isn't logic-oriented, rule-oriented, or constraint-oriented are true since PHP doesn't support any of those programming styles but it does support procedure-oriented and object-oriented.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  4. #4
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Even though java has great support for OO, you can still code in a procedural manor. There's plenty of java code out there that is nothing more than a big god class with a bunch of methods that are called sequentially. Despite java requiring all code be in classes, that doesn't really make it OO code.

    Javascript is OO too. And there's tons of procedural code written in it.

    The language needs to provide some support, but it's still up to the programmer to write code that adheres to the principals. With that said, I think php provides pretty decent support for it.

  5. #5
    SitePoint Evangelist
    Join Date
    Jun 2007
    Posts
    496
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP also support OOP, but Java is only OOP based language.

  6. #6
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,862
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by crmalibu View Post
    Even though java has great support for OO, you can still code in a procedural manor. There's plenty of java code out there that is nothing more than a big god class with a bunch of methods that are called sequentially. Despite java requiring all code be in classes, that doesn't really make it OO code.

    Javascript is OO too. And there's tons of procedural code written in it.

    The language needs to provide some support, but it's still up to the programmer to write code that adheres to the principals. With that said, I think php provides pretty decent support for it.
    There is also lots of spaghetti code written in all those languages. Just because a language supports procedure oriented doesn't mean that people will use even that - particularly those who haven't been taught and of the programming methodologies and therefore don't understand what procedure oriented, object oriented, rules oriented, logic oriented, or constraint oriented programming are (I don't really understand the last two either having only learnt three programming methodologies myself).
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •