hello!
I have a class method that takes a variable number of parameters and
correctly deals with them with func_get_args, etc ...
i.e.
class ABC
{
public function MooSaysTheCow()
{
foreach (func_get_args( ) as $arg_name => $arg_value)
{
...
}
}
}
now, the problem is: i want to override this class and this method, have
that overriding method call the base class and then do something else. The
problem is that I don't know how to pass the parameters along.
class DEF
{
public function MooSaysTheCow()
{
parent::MooSays TheCow( WHAT DO I PUT HERE ????? );
echo "Overridden version with new exciting features!";
}
}
Any ideas?
the best i've thought of so far is terribly yucky, and not flexible to
arbitrary numbers of parameters .... blech.
class DEF
{
public function MooSaysTheCow()
{
switch (func_get_num_a rgs())
{
case 1:
parent::MooSays TheCow(func_get _arg(0));
break;
case 2:
parent::MooSays TheCow(func_get _arg(0), func_get_arg(1) );
break;
etc ....
...
.. 11 4136
Mark wrote: hello!
I have a class method that takes a variable number of parameters and correctly deals with them with func_get_args, etc ...
i.e.
class ABC { public function MooSaysTheCow() { foreach (func_get_args( ) as $arg_name => $arg_value) { ... } } }
now, the problem is: i want to override this class and this method, have that overriding method call the base class and then do something else. The problem is that I don't know how to pass the parameters along.
Check the comments for
<http://www.php.net/manual/en/function.func-get-args.php> class DEF { public function MooSaysTheCow() { parent::MooSays TheCow( WHAT DO I PUT HERE ????? ); echo "Overridden version with new exciting features!"; } }
Any ideas?
the best i've thought of so far is terribly yucky, and not flexible to arbitrary numbers of parameters .... blech.
class DEF { public function MooSaysTheCow() { switch (func_get_num_a rgs()) { case 1: parent::MooSays TheCow(func_get _arg(0)); break; case 2: parent::MooSays TheCow(func_get _arg(0), func_get_arg(1) ); break; etc .... ... .. . } } }
thanks. mark.
did you try to pass the return value of func_get_args() ?
"Mark" <mw@ANGRYLanfea r.com> wrote in message
news:Is******** ************@nv enture.com... hello!
I have a class method that takes a variable number of parameters and correctly deals with them with func_get_args, etc ...
i.e.
class ABC { public function MooSaysTheCow() { foreach (func_get_args( ) as $arg_name => $arg_value) { ... } } }
now, the problem is: i want to override this class and this method, have that overriding method call the base class and then do something else. The problem is that I don't know how to pass the parameters along.
class DEF { public function MooSaysTheCow() { parent::MooSays TheCow( WHAT DO I PUT HERE ????? ); echo "Overridden version with new exciting features!"; } }
Any ideas?
the best i've thought of so far is terribly yucky, and not flexible to arbitrary numbers of parameters .... blech.
class DEF { public function MooSaysTheCow() { switch (func_get_num_a rgs()) { case 1: parent::MooSays TheCow(func_get _arg(0)); break; case 2: parent::MooSays TheCow(func_get _arg(0), func_get_arg(1) ); break; etc .... ... .. . } } }
thanks. mark.
-- I am not an ANGRY man. Remove the rage from my email to reply.
Ashlee Simpson Sings! You Faint .... --More-- Ashlee Simpson Sings! Ashlee Simpsons sings! You die ... --More--
On Tue, 07 Dec 2004 15:37:52 -0800, Mark <mw@ANGRYLanfea r.com> wrote: I have a class method that takes a variable number of parameters and correctly deals with them with func_get_args, etc ...
i.e.
class ABC { public function MooSaysTheCow() { foreach (func_get_args( ) as $arg_name => $arg_value) { ... } } }
now, the problem is: i want to override this class and this method, have that overriding method call the base class and then do something else. The problem is that I don't know how to pass the parameters along.
class DEF { public function MooSaysTheCow() { parent::MooSays TheCow( WHAT DO I PUT HERE ????? ); echo "Overridden version with new exciting features!"; } }
Any ideas?
the best i've thought of so far is terribly yucky, and not flexible to arbitrary numbers of parameters .... blech.
class DEF { public function MooSaysTheCow() { switch (func_get_num_a rgs()) { case 1: parent::MooSays TheCow(func_get _arg(0)); break; case 2: parent::MooSays TheCow(func_get _arg(0), func_get_arg(1) ); break; etc .... ... .. . } } }
What am I missing here; can't you just use func_get_args() to pass the
arguments upwards?
--
Andy Hassall / <an**@andyh.co. uk> / <http://www.andyh.co.uk >
<http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool
Dani CS wrote: Check the comments for <http://www.php.net/manual/en/function.func-get-args.php>
Close!
func_get_args() doesn't work because the parent function has to then be
expecting an array parameter, not a list of parameters as normal (and i do
NOT have control over the parent implementation -- it's a prepackaged
class).
i was moderately hopeful when I saw the function call_user_func_ array,
which does what i want -- takes an array with parameters and calls the
function with the array values as normal arguments
EXCEPT -- that won't work within classes, expeshully in the __construct
method ...
argh.
any other ideas?
thanks!
mark.
I'm typing this without testing it, but it seems like it would work. I'm
sure you take a performance hit from the eval() call, though.
$argList = '';
for($n=0;$n<fun c_get_num_args( );$n++)
$argList .= "func_get_arg($ n),";
$argList = rtrim($argList, ',');
/* $argList will not be a string that looks like
"func_get_art(0 ),func_get_arg( 1),func_get_arg (2)", repeating for however
many arguments have been passed*/
eval("parent::M ooSaysTheCow($a rgList);");
Worth a shot.
.oO(Mark) I have a class method that takes a variable number of parameters and correctly deals with them with func_get_args, etc ... [...]
now, the problem is: i want to override this class and this method, have that overriding method call the base class and then do something else. The problem is that I don't know how to pass the parameters along.
class DEF { public function MooSaysTheCow() { parent::MooSays TheCow( WHAT DO I PUT HERE ????? ); echo "Overridden version with new exciting features!"; } }
Try
public function MooSaysTheCow() {
$args = func_get_args() ;
call_user_func_ array(array('pa rent', 'MooSaysTheCow' ), $args);
}
Micha
"Michael Fesser" <ne*****@gmx.ne t> wrote in message
news:hf******** *************** *********@4ax.c om... Try
public function MooSaysTheCow() { $args = func_get_args() ; call_user_func_ array(array('pa rent', 'MooSaysTheCow' ), $args); }
Very clever. Mark, please report back and let us know if this works for
you!
Joshua Beall wrote: "Michael Fesser" <ne*****@gmx.ne t> wrote in message news:hf******** *************** *********@4ax.c om... Try
public function MooSaysTheCow() { $args = func_get_args() ; call_user_func_ array(array('pa rent', 'MooSaysTheCow' ), $args); }
Very clever. Mark, please report back and let us know if this works for you!
nope. probably would have in PHP4, but most certainly not in PHP5.
i'm still stuck with the switch statement in PHP5, unfortunately.
argh!
mark.
--
I am not an ANGRY man. Remove the rage from my email to reply.
Andy Hassall wrote: On Tue, 07 Dec 2004 15:37:52 -0800, Mark <mw@ANGRYLanfea r.com> wrote: What am I missing here; can't you just use func_get_args() to pass the arguments upwards?
no. at least not in overloaded methods in classes.
the problem is that the overloadER and the overloadEE are both looking for
variable argument lists. func_get_args() returns an ARRAY.
now, the obvious (lame) solution would be to modify both functions to just
take arrays of arguments but ... i don't have control over the base class's
implementation (it's the mysqli class).
so, i appear to be stuck with the switch statement way of doing things.
d'oh!
thanks,
mark.
--
I am not an ANGRY man. Remove the rage from my email to reply. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Eric A. Forgy |
last post by:
Hello,
I am just learning Java and am trying to write a method that does
something like
//===========================================
public Static List find(double array,double val,String relationalOp)
{
List list = new ArrayList();
|
by: cirillo_curiosone |
last post by:
Hi,
i'm new to javascript. I started studing it on the web few weeks ago,
but still haven't been able to solve one big problem: HOT TO PASS VALUES
FROM A SCRIPT VARIABLE TO A CHILD HTML GENERATED BY FUNCTION.
Here'e the point:
I'm writing a simple website for showing my photographs. It has a
central page with many links (as many as galleries are).
|
by: Greg Swindle |
last post by:
Hello,
I have a question about how prototyping relates to variables and their
scope.
Given the following code:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var ParentObject = function()
{
var objectName = "ParentObject";
|
by: Lyn |
last post by:
Hi,
I have a Search input form which collects from the user a person's name. I
am using LIKE with a "%" suffix in the SQL so that the user does not have to
type in the full name. When they hit the Search button, a query is run to
search the Person table for a match. This produces a recordset (I am using
ADO).
If the RecordCount is zero, they get a No Match message.
If the RecordCount is 1, a DoCmd.OpenForm is performed to open the...
|
by: truckaxle |
last post by:
I am trying to pass a slice from a larger 2-dimensional array to a
function that will work on a smaller region of the array space. The
code below is a distillation of what I am trying to accomplish.
// - - - - - - - - begin code - - - - - - -
typedef int sm_t;
typedef int bg_t;
sm_t sm;
bg_t bg;
| |
by: |
last post by:
Hi,
1st, I did a search and could not find any info on this, the Google results
were good, but I'm still have issues...So any help will be great.
I have a frame page, which contains 3 frames (Left, Content, and Footer)
In the content page, I have a checkbox, which value is a number (i.e. 500).
I would like that, when a user clicks on this checkbox, it will send the
value to my LEFT frame.
My left frame has an array, where I'm going to...
|
by: ged |
last post by:
Hi,
i am a oo (c#) programmer, and have not used javascript for a while and
i cant work out how javascript manages its references. Object
References work for simple stuff, but once i have an object collection
and stanrd using it it starts to fall apart.
Clearly there is something about javascript's usage of passing "By ref"
that i am not getting. i have had a look on the web and found some
examples, but i cant see why my code does not...
|
by: virgincita schmidtmann |
last post by:
Good evening,
I would like to pass the size of an array from the commandline.
int main(int argc, int *argv) {
....
max=*argv;
int list;
....
|
by: zman77 |
last post by:
EDIT: -- forgot to mention... I am using Visual Studio 2005, on Win XP, on an intel machine
Hi.
This is my first post, though I've "lurked" for a while because I find these forums very helpful.
Ok my problem is the following. I have a class that contains a "MakeByteArray" function.
I have many objects of that class. Inside that function, I have a private variable,
that is NOT static. It seems that when I put all these objects in...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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,...
| |
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...
|
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,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |