467,107 Members | 1,220 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,107 developers. It's quick & easy.

PHP equivalent to super()?

[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]

hello world
what is up with your bad self
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
Jul 17 '05 #1
  • viewed: 49416
Share:
3 Replies
Check out this page in the manual:
http://www.php.net/manual/en/keyword.parent.php

--
Tony Marston

http://www.tonymarston.net
"Phil Powell" <so*****@erols.com> wrote in message
news:1c**************************@posting.google.c om...
[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]

> hello world
what is up with your bad self

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

Jul 17 '05 #2
"Tony Marston" <to**@NOSPAM.demon.co.uk> wrote in message news:<c9*******************@news.demon.co.uk>...
Check out this page in the manual:
http://www.php.net/manual/en/keyword.parent.php
Ah, that's why I couldn't find it, it wasn't identified as PHP version
of the Java "super" keyword that I could find on the page, thanx

Phil

--
Tony Marston

http://www.tonymarston.net
"Phil Powell" <so*****@erols.com> wrote in message
news:1c**************************@posting.google.c om...
[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]

> > hello world
what is up with your bad self

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

Jul 17 '05 #3
It is not the function of the PHP manual (or any other language manual for
that matter) to identify the equivalent terminology in Java. That is why
searching the manual using Java keywords is not a good idea.

--
Tony Marston

http://www.tonymarston.net

"Phil Powell" <so*****@erols.com> wrote in message
news:1c**************************@posting.google.c om...
"Tony Marston" <to**@NOSPAM.demon.co.uk> wrote in message

news:<c9*******************@news.demon.co.uk>...
Check out this page in the manual:
http://www.php.net/manual/en/keyword.parent.php


Ah, that's why I couldn't find it, it wasn't identified as PHP version
of the Java "super" keyword that I could find on the page, thanx

Phil

--
Tony Marston

http://www.tonymarston.net
"Phil Powell" <so*****@erols.com> wrote in message
news:1c**************************@posting.google.c om...
[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]

> > > hello world
what is up with your bad self

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

Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Kerim Borchaev | last post: by
2 posts views Thread by Clarence Gardner | last post: by
11 posts views Thread by Nicolas Lehuen | last post: by
reply views Thread by Delaney, Timothy C (Timothy) | last post: by
6 posts views Thread by Steven Bethard | last post: by
9 posts views Thread by Paul Rubin | last post: by
1 post views Thread by duzhidian@gmail.com | last post: by
18 posts views Thread by Richard Szopa | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.