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

Home Posts Topics Members FAQ

access parent method php4

RR
I have two classes:

class Base
{
function Insert()
{
// does stuff
}
}

class Derived extends Base
{
function Insert()
{
// does some different stuff
parent::Insert( ); // then calls base class
}
}

Now, in main line code I want to do this:

$der = new Derived();

$der->parent::Insert (); // I want to call the base class's Insert
method - doesn't work

$der->Base::Insert() ; // this doesn't work either

Is it possible to access a hidden parent class method with a child class
object in PHP4?

thanks,
RR
Jul 17 '05 #1
3 4796
With total disregard for any kind of safety measures "RR"
<ne************ ****@spamgourme t.com> leapt forth and uttered:
I have two classes:

class Base
{
function Insert()
{
// does stuff
}
}

class Derived extends Base
{
function Insert()
{
// does some different stuff
parent::Insert( ); // then calls base class
}
}

Now, in main line code I want to do this:

$der = new Derived();

$der->parent::Insert (); // I want to call the base
class's Insert method - doesn't work

$der->Base::Insert() ; // this doesn't work either

Is it possible to access a hidden parent class method with a
child class object in PHP4?

thanks,
RR


When you extend a class you override any methods from the parent
class that have the same name. But if you just call $der->insert()
then it should work as long as Derived::insert () includes the call
to it's parent method.

--
Phil Roberts | Dork Pretending To Be Hard | http://www.flatnet.net/
Jul 17 '05 #2
RR,

I guess you need to write an aditional method:

class Derived extends Base
{
function Insert()
{
// does some different stuff
parent::Insert( ); // then calls method from base class
}

functon baseInsert()
{
parent::Insert( );
}
}
then call $der->basInsert();

Alternativily you could rename the Direved::Insert () method:
class Derived extends Base
{
function extendedInsert( )
{
// does some different stuff
$this->Insert(); // then calls inherited method
}
}

These two solutions will give different polymorphisms for Insert(). I
mean, if you can have arrays like:

$polymorhicArra y = array( new Base(), new Derived(), new Base() );

and you would want to do:

forEach ($polymorhicArr ay as $baseOrDerived)
$baseOrDerived->Insert();

Then i guess only one of the above solutions will do what you want.

Greetings,

Henk Verhoeven,
www.phpPeanuts.org.

RR wrote:
I have two classes:

class Base
{
function Insert()
{
// does stuff
}
}

class Derived extends Base
{
function Insert()
{
// does some different stuff
parent::Insert( ); // then calls base class
}
}

Now, in main line code I want to do this:

$der = new Derived();

$der->parent::Insert (); // I want to call the base class's Insert
method - doesn't work

$der->Base::Insert() ; // this doesn't work either

Is it possible to access a hidden parent class method with a child class
object in PHP4?

thanks,
RR


Jul 17 '05 #3
RR

"Henk Verhoeven" <ne**@metaclass REMOVE-THIS.nl> wrote in message
news:c3******** **@news3.tilbu1 .nb.home.nl...
I guess you need to write an aditional method:

class Derived extends Base
{
function Insert()
{
// does some different stuff
parent::Insert( ); // then calls method from base class
}

functon baseInsert()
{
parent::Insert( );
}
}
then call $der->basInsert();


Thanks. That's what I did....just hoping for a better (more direct)
solution.

RR
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
7666
by: Robert | last post by:
I am using the php4-cgi Debian package which is based on PHP 4.3.4. I have problems when running php4 on the command line. If I say something like $ php4 index.cgi a number of variables are not initialized. For example, $HTTP_GET_VARS is not set. To get it set, here's my workaround:
14
3804
by: pablo | last post by:
Dear NewsGroupers, I am relatively new to OOP and cannet get my head around this problem. I have two classes. Class Child extends Parent. There is no constructor for the Child class. So when I create a child object the constructor for the parent object is called. That works fine. But now I have the problem that I want to add an already existing Parent object to create a new Child object. How can this be done?
49
14322
by: Yannick Turgeon | last post by:
Hello, We are in the process of examining our current main application. We have to do some major changes and, in the process, are questionning/validating the use of MS Access as front-end. The application is relatively big: around 200 tables, 200 forms and sub-forms, 150 queries and 150 repports, 5GB of data (SQL Server 2000), 40 users. I'm wondering what are the disadvantages of using Access as front-end? Other that it's not...
3
1870
by: Ray Mitchell | last post by:
Hello, I am opening a modal dialog in the standard way using something like: ....all the standard setup stuff... dlg.ShowDialog(); I need the dialog object to be able to access some of the methods back in the object that created it (the code above). Is there some attribute, method, or whatever within the dialog object that provides such access or do
3
1840
by: Antuane | last post by:
hi guys, its me again, with a few simple (probably silly) quesetion... hi guys, i've managed to create a custom textbox class. & i'd like to access the parent control (in this case this would be the form, cuz i drop the textbox onto the form), in the constructor of the custom textbox class. i'd like to access the parent control in the constructur of the textbox. But i can't do this, cuz i get an error, saying that the parent property...
4
1353
by: Danny Tuppeny | last post by:
Hi all, The next few paragraphs put my question in context, but feel free to skip down to the end if you don't care *why* I need the answer! :) **************************************** *** Start of long-winded description *** **************************************** I've got some classes that define a tree structure. When the Parent
3
2717
by: danish | last post by:
Hi, Can anyone tell me how to access oracle from php. Im using CentOS 4 with php4 already installed. From what I found after a bit of googling...php will have to be recompiled with oracle support. This seems to be a lot tedious. Anyone with an advic on how to use oracle with php. Im using CentOS4 php4 oracle10g
1
2581
by: vegascoop | last post by:
I'm moving a script from PHP4 to PHP5. Everything works under PHP4. When I run the script under PHP5, I get the following error message: Call to undefined method Database::doQuery() Here is the offending code: function getBaseURL( ) {
2
3212
by: Harris Kosmidhs | last post by:
Hello, I have an AppController and some classes that extend the controller. I.e: class UsersController extends AppController { function UsersController() { parent::AppController();
0
8305
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8823
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8726
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8603
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6163
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4151
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2726
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 we have to send another system

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.