473,508 Members | 2,489 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
3 50340
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2309
by: Kerim Borchaev | last post by:
Hello! Always when I use "super" I create a code duplication because class used as first arg to "super" is always the class where the method containing "super" was defined in: ''' class C:...
2
1663
by: Clarence Gardner | last post by:
The super object is considered a solution to the "diamond problem". However, it generally requires that the ultimate base class know that it is last in the method resolution order, and hence it...
11
5012
by: Nicolas Lehuen | last post by:
Hi, I hope this is not a FAQ, but I have trouble understanding the behaviour of the super() built-in function. I've read the excellent book 'Python in a Nutshell' which explains this built-in...
0
1488
by: Delaney, Timothy C (Timothy) | last post by:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/286195 This is a new version of super that automatically determines which method needs to be called based on the existing stack frames....
6
1998
by: Steven Bethard | last post by:
When would you call super with only one argument? The only examples I can find of doing this are in the test suite for super. Playing around with it: py> class A(object): .... x = 'a'...
9
1699
by: Paul Rubin | last post by:
I'm trying the super() function as described in Python Cookbook, 1st ed, p. 172 (Recipe 5.4). class A(object): def f(self): print 'A' class B(object): def f(self):
3
2056
by: Amelyan | last post by:
When we want radio button to belong to a group name we say, radio1.GroupName="GroupA". In this case, radio1 will be unselected if another radio button is selected in "GroupA". Is there a way...
1
2035
by: duzhidian | last post by:
Dear All: I need write a php program online to implement a super search engine, for example, when users input some keyword, my program can search different other online search engines and reply...
18
2471
by: Richard Szopa | last post by:
Hello all, I am playing around w/ Python's object system and decorators and I decided to write (as an exercise) a decorator that (if applied to a method) would call the superclass' method of the...
0
7231
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7405
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5643
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5059
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4724
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3214
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1568
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
773
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
435
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.