NYCPHP Meetup

NYPHP.org

[nycphp-talk] Does PHP have an equivalent to super()?

Phillip Powell phillip.powell at adnet-sys.com
Wed Jun 2 10:48:04 EDT 2004


[PHP]
<?php

  class SuperClass {

     var $mySuperClassVar;

     function SuperClass($myVar) {
       $this->mySuperClassVar = $myVar;
       echo "super class var = $myVar<p>";
     }

  }

  class SubClass extends SuperClass {

    var $mySubClassVar;

    function SubClass($myVar) {
     // super('hello world?')???
     $this->mySubClassVar = $myVar;
     echo "sub class var = $myVar<p>";
    }

  }

  $obj =& new SubClass('what is up with your bad self');

?>
[/PHP]

[output]
  hello world
  what is up with your bad self
[/output]

I am interested in finding out if PHP has an equivalent to the Java 
"super" keyword that evokes methods or constructor of the class' parent 
class.  I can't find anything online on this and hoped maybe one of you 
guys came up with a nice workaround for this in PHP 4.3.2+ that I could 
learn.  Or point me in the right, open-source, direction for me to 
figure this out.

Thanx
Phil

-- 
---------------------------------------------------------------------------------
Phil Powell
Multimedia Programmer
BPX Technologies, Inc.
#: (703) 709-7218 x107 
Fax: (703) 709-7219

	




More information about the talk mailing list