By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,640 Members | 1,581 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,640 IT Pros & Developers. It's quick & easy.

PHP equivalent to super()?

P: n/a
[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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
"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

P: n/a
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.