Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,830
    Thanks
    21
    Thanked 157 Times in 148 Posts

    Question PHP4 OOP questions

    I haven't done OOP with PHP4 in awhile....So I have 2 questions:

    1) Can you instantiate a class if it has no constructor?

    2) If a class inherits from a base class, are the base class functions publicly available via an instance of the derived class?

    What I'm trying to do is prevent my base class from being instantiated directly, and prevent my base class functions from being publicly available via a derived class object.

    Thanks.
    Last edited by chump2877; 11-25-2007 at 09:54 PM.
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :-)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!
    ♪♪ …Need Web Hosting For My YouTube-To-Mp3 Conversion Software? Check Here !!… ♪♪

  • #2
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    How long would it take you to try it and see? I can't imagine more than a couple of minutes if you have 4 installed (I don't...), but something along the lines of:
    PHP Code:
    class Foo {
      function 
    bar() {}
    }
    $foo = new Foo();
    var_dump($foo); 
    and
    PHP Code:
    class Foo {
      function 
    fooble() {
        echo 
    "Fooble was called";
      }
    }

    class 
    Bar extends Foo {
      
    }

    $bar = new Bar();
    $bar->fooble(); 
    The things you're trying to do can be done easily with PHP5, so upgrade already!
    My thoughts on some things: http://codemeetsmusic.com
    And my scrapbook of cool things: http://gjones.tumblr.com

  • #3
    Regular Coder
    Join Date
    May 2004
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I want to try using php5 but my oop skills aren't the best. I'm looking onlince for resources to teach myself, but when i read about classes in php5 they seem more complicated than what i'm used to. Is there that big of a difference in php5's version? And can anyone recommended a big for a php5 beginner like me?

    thanks,
    c.c.

  • #4
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,830
    Thanks
    21
    Thanked 157 Times in 148 Posts
    This is the best reference to learn PHP5 OOP...It's what I used....

    There are probably tutorials that are geared more towards people who aren;t familiar with OOP, but I don;t personally know of any...

    PHP4 OOP is kind of a joke, since it is lacking lots of OOP features of other languages (and PHP5)...So you may want to read a book on general OOP or learn a strong OOP language (like C# -- that's what I learned) before you try to grasp the concepts of PHP5 OOP....Otherwise, I can see how the transition between PHP4 OOP and PHP5 OOP can be hard if you don;t understand the general principles of OOP.
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :-)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!
    ♪♪ …Need Web Hosting For My YouTube-To-Mp3 Conversion Software? Check Here !!… ♪♪


  •  

    Posting Permissions

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