Is PHP an object oriented programing language?

Discussion in 'PHP' started by bilalownsu, Jan 22, 2009.

  1. #1
    Like the title says:
    Is PHP an object oriented programing language like Java?
    and how similar is to Java?
    Also what is the best code editor for PHP and is there a GUI builder for PHP?

    I have taken 3 years of programming courses(2 years of Java + 1 year Visual Basic).
     
    bilalownsu, Jan 22, 2009 IP
  2. CTThompson

    CTThompson Member

    Messages:
    68
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #2
    PHP is object oriented. You can create classes.

    In my opinion it is slightly similar to Java. PHP is based on C. In my opinion, PHP is easier than Java.

    As for code editors, I have never used one. I write text files and upload them to a test server for testing. A code editor will use emulation. I find it easier to upload to the server and see a real-time example with the server php settings that will be used.
     
    CTThompson, Jan 22, 2009 IP
  3. r0kawa

    r0kawa Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I have just to agree with CTThompson. PHP is an OO language. Using PHP 5.3 (beta) , you'll have extra namespace support.

    PHP OO is more like C++ than like Java. PHP can be mix with procedural and OO . There's a lot of editor you can use. Aptana (eclipse based), Netbeans for PHP or an simple plain PSPAD is also recommended. You can find a few paid based editor like Zend, Comodo.
     
    r0kawa, Jan 22, 2009 IP
  4. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #4
    Yes. Its OOP
    Use Adobe Dreamweaver CS4 for editor
    Very similar to Java in OOP but not in building UI,php uses html.
    Same client-server relation.
     
    bartolay13, Jan 22, 2009 IP
  5. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #5
    PHP isn't object oriented, it has bolted on support for objects and namespaces.

    To get into teritory familiar to you from a Java perspecitve you're going to have to start out using one of the common frameworks like Symphony, Zend, or cake.
    Comming from Java you're probably familiar with Eclipse, I believe you can use that for PHP as well.
     
    joebert, Jan 23, 2009 IP
  6. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #6
    php5 is not full oop. php is not designed for gui, it's designed for cli and browser output. If you really need gui, use php-gtk.
     
    Kaizoku, Jan 23, 2009 IP
  7. Gonzo4u

    Gonzo4u Well-Known Member

    Messages:
    410
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    110
    #7
    It is true that PHP is not a truly Object-Oriented Language, basic object-oriented programming functionality was added in PHP 3 and from then on its improving a lot current version PHP 5.3(beta) has more objects and namespaces support.

    It is somewhat similar to Java except syntax.

    If your planning to learn then I advice you not to use any editors, instead use a text editor for your coding, that will help you a lot in understanding and learning a programming language better. Editors or UI builders for any programming languages use code emulations and most of the coding is taken care by them. So, as a learning perspective use a text editor and then you can switch to any UI builders or Editors.

    Regards,
    Gonzo
     
    Gonzo4u, Jan 23, 2009 IP
  8. programmersbank

    programmersbank Peon

    Messages:
    184
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #8
    PHP is an object oriented language, it uses functions, classes, includes

    Its syntax is similar to java and C++

    You can create function and classes in separate files and then you can call these functions and classes and call in any page after include this file.

    In php you can also include text files as well as any extension as you want

    You dont need specific editor for this, you can all php work in Dreamweaver. It better support php
     
    programmersbank, Jan 23, 2009 IP
  9. bilalownsu

    bilalownsu Peon

    Messages:
    122
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Thanks everyone for your responses, I really appreciate the help.
    I am happy to hear that you can create object and classes in php :). I have been using eclipse to create my java programs so I will just use it for my php programs.
     
    bilalownsu, Jan 23, 2009 IP
  10. mrmaf

    mrmaf Peon

    Messages:
    41
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Yeah php is a powerful object oriented programming language.
     
    mrmaf, Jan 23, 2009 IP
  11. Neticule

    Neticule Well-Known Member

    Messages:
    491
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    108
    #11
    Indeed, php is quite powerful once you dive in, I love it, its one of those languages that you can use at almost any skill level.
     
    Neticule, Jan 23, 2009 IP
  12. Dennis M.

    Dennis M. Active Member

    Messages:
    119
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #12
    Java is not so much like PHP. The basic OOP capabilities is really all they have in common. For starters, PHP is parsed by the web server with no client-side needs to process properly. However, this can be more limited seeing as it is for site functionality and not applets, etc.

    If you have any knowledge of C++ you'll be in great shape though. PHP is a down-scaled C++ for the web. (In simple terms) The include functions are there the major difference is since PHP is a web language, you don't define variables by type. (E.g.: int, char, float, long int, etc.) Instead, you'll be preceding the variables with a dollar sign ($). Also, you're # will comment instead of #include "header_file.h" or something. Basic syntax, however, follows the exact pattern in both C++ and PHP.

    Regards,
    Dennis M.
     
    Dennis M., Jan 24, 2009 IP
  13. mdrobiul

    mdrobiul Peon

    Messages:
    186
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Hello everyone here, how some guys are saying that PHP is not a OOP ? What I should say officially ? Yes or no!
     
    mdrobiul, Jan 25, 2009 IP
  14. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #14
    PHP is flexible, if you want it oop, then it is. If you want it procedural, then it is too. IT is BOTH.
     
    Kaizoku, Jan 25, 2009 IP
  15. InFloW

    InFloW Peon

    Messages:
    1,488
    Likes Received:
    39
    Best Answers:
    0
    Trophy Points:
    0
    #15
    PHP is an object oriented programming language.


    
    Class Pet
    {
    
    }
    
    Class Dog extends Pet
    {
    
    }
    $pet = new Dog();  // I created an OBJECT!
    
    PHP:
    Is it a great object oriented language now that is up for debate.

    Of course there is no perfect OO language no one agrees. C++ you can inherit from multiple classes. While Java you cannot (you can do implements but not the same).

    So PHP's issue is with so many beginners they could be using objects for no reason at all just because a tutorial said to. The same could be said about other languages to of course. It's just PHP is a lot easier to pickup than a lot of other languages so you see it more often.
     
    InFloW, Jan 25, 2009 IP
  16. nomzz

    nomzz Well-Known Member

    Messages:
    475
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    110
    #16
    Even C++ is not pure object oriented language if you wana know whats OOPS design start reading Design Patterns. And no PHP is not pure object oriented making classes and functions dosent make language OOP.
     
    nomzz, Jan 25, 2009 IP
  17. brettcave

    brettcave Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #17
    The fundamentals in defining an OOP are:
    • Class - php supports classes
    • Object - "pattern of a class" - yes
    • Instance - yes
    • Method - yes (aka "function")
    • Message passing - yes. 1 object can invoke another objects methods.
    • Inheritance - php supports inheritance after v5 (i think). "class User extends Person"
    • Abstraction - yes. 1 class can have other classes as types, without the instantiating code needing to know about the other classes the top level class uses. E.g. for the "user" class mentioned above, code the instantiates User doesnt need to know about the class "Person" as person would be handled internally to "user".
    • Encapsulation - methods or fields can be encapsulated in php, by the use of "private" "protected" and "public" keywords. "private static $name; public function getName() {}"
    • Polymorphism - yes - this is also known as overriding and overloading. a person class may have a method called "sendMessage". "user" class may override this method to perform different tasks, while a "student" class that also extends "person" may perform totally different code. Both student and user call the same method that is defined in person, but may have different results.
    • Decoupling - yes. loosely, this is the reuse of code. for example, a person class may initialise certain variables. you could then use the default constructor of sub-classes (user / student) to call methods in the superclass. e.g. in student: function __construct() { $this->person = new Person(); } The function __construct in person may then may call "session_start" set a variable is_real to true and some other functions.

    More info on these concepts can be found on wikipedia. So based on these programming concepts, PHP is OOP.
     
    brettcave, Feb 16, 2009 IP
  18. cancer10

    cancer10 Guest

    Messages:
    364
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #18
    Hi


    I have come across this article which explains that PHP is not purely an OO language.

    http://www.hiteshagrawal.com/php/php5-tutorial-not-pure-object-oriented-programming-approach


    Anyone second me?
     
    cancer10, Sep 2, 2009 IP