Results 1 to 3 of 3

Thread: OO in PHP 5

  1. #1

    Talking OO in PHP 5

    Been reading about the enhancements in PHP 5, and may answer the prayers of the shortcomings of PHP 4. While the implimentation of OO is not perfect, it is WAY better and offers a more streamlined approach to code, which means reusuability... now I am not saying PHP code had never used reusuable code, but this makes it better.

    I just finished an article regarding the new features, and I am quite excited! http://www.developer.com/lang/php/ar...0941_3302171_1

    I have a local beta running... seems nice

  2. #2
    Junior Member
    Join Date
    Dec 2003
    Posts
    24
    Agreed.

    Some new features:

    Private and protected class variables. Something I look forward to, if only for the fact that it brings it closer to C++ style which I am more familiar.

    Unified constructors. This I like a lot. It basically means that the contructor of any class has the same name, not just a function named after the class.
    For instance:

    old way
    PHP Code:
    class one
    {
         function 
    one()
         {
            
    //this is the constructor
         
    }

    new way
    PHP Code:
    class one
    {
         function 
    __construct()
         {
             
    //this is the constructor
         
    }

    I like this because, as noted on php.net, it allows you to access the parent class' constructor without knowing what the parent class' name is. Obviously you will need to know what the parent class is, but if you want to use a different parent down the road you don't need to modify the code within the class, just the class definition.

    I'm looking forward to other changes in PHP5 as well. I think it will be a big step forward for the language.

    For more change info, click here

  3. #3
    AO Antique pwaring's Avatar
    Join Date
    Aug 2001
    Posts
    1,409
    PHP 5 looks really cool with all the OO features that are being added, but I think take-up will be rather slow - PHP 4 has been out for years yet there are still a lot of sites running pre-4.1 versions and even PHP 3. Also, I don't think the new features will be sufficient to encourage most web hosts to upgrade within a couple of months of the first stable release.
    Paul Waring - Web site design and development.

Posting Permissions

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