Re: [PHP] Variable functions within an object

2004-07-30 Thread Julio Sergio Santana
Curt Zirzow wrote: or for the oneline purists :) ${ ${$this->fname} = $this->fname }(); wow.. ${} is more powerful than i had originally though. Thank you Curt, With your suggestion, I finally re-wrote the example, and here it is: function foo() { echo "In foo()\n"; } class a { var $fname;

Re: [PHP] Variable functions within an object

2004-07-30 Thread Curt Zirzow
* Thus wrote Julio Sergio Santana: > > Curt Zirzow wrote: > > > $this->{$this->fname}(); > > > > or (what it actually is doing.. ) > > > > $func = $this->fname; > > $this->$func(); > > > >Curt > > The point here is that the named function is outside the object. That > is, $this->foo() doesn

Re: [PHP] Variable functions within an object

2004-07-30 Thread Julio Sergio Santana
Curt Zirzow wrote: $this->{$this->fname}(); or (what it actually is doing.. ) $func = $this->fname; $this->$func(); Curt The point here is that the named function is outside the object. That is, $this->foo() doesn't exist, so $this->{$this->fname}(), does not work either. But if you look

Re: [PHP] Variable functions within an object

2004-07-29 Thread Jason Davidson
http://ca3.php.net/manual/en/function.call-user-func.php ? Jason On Thu, 29 Jul 2004 17:11:50 -0500, Julio Sergio Santana <[EMAIL PROTECTED]> wrote: > I need to record the names of functions, and then use them later. > Recently I found the following example within the on-line documentation: >

Re: [PHP] Variable functions within an object

2004-07-29 Thread Curt Zirzow
* Thus wrote Julio Sergio Santana: > > class a { > var $fname; > function a() { > $this->fname = 'foo'; // the name of the function > } > > function execute() { // method to execute the named function > $this->fname(); > // I also tried here > // {$this->fname}(); > //

[PHP] Variable functions within an object

2004-07-29 Thread Julio Sergio Santana
I need to record the names of functions, and then use them later. Recently I found the following example within the on-line documentation: \n"; } $func = 'foo'; $func();// This calls foo() ?> then I supposed that it was easy to extend this concept to objects and wrote the following case:

Re: [PHP] Variable Functions...

2003-07-10 Thread Burhan Khalid
On Friday, July 11, 2003, 3:11:51 AM, Michael wrote: MS> Smarty has a class method where it calls: $this->$some_var("somevalue"); Are you sure about that syntax? I'm not too familiar with Smarty, only used it once, but I think its $this->some_var("value"); MS> and this throws errors on Windows

[PHP] Variable Functions...

2003-07-10 Thread Michael Smith
Smarty has a class method where it calls: $this->$some_var("somevalue"); and this throws errors on Windows versions of php that i've tried. why is that? -Michael -- Pratt Museum IT Intern All programmers are playwrights and all computers are lousy actors. -- PHP General Mailing List (http://www

Re: [PHP] variable functions: empty/isset/unset invalid?

2001-05-07 Thread Gyozo Papp
> > Kirk > > > -Original Message- > > From: Philip Olson [mailto:[EMAIL PROTECTED]] > > Sent: Monday, May 07, 2001 11:45 AM > > To: [EMAIL PROTECTED] > > Subject: RE: [PHP] variable functions: empty/isset/unset invalid? > > > > > &g

Re: [PHP] variable functions: empty/isset/unset invalid?

2001-05-07 Thread Christian Reiniger
On Monday 07 May 2001 20:11, Johnson, Kirk wrote: > problem for empty(). Also, a User Contributed Note at > http://www.php.net/manual/en/functions.php#functions.user-defined has > this to say: > > > there are tons of good uses for this sort of functionality. But it > should be noted that this wi

RE: [PHP] variable functions: empty/isset/unset invalid?

2001-05-07 Thread Altunergil, Oktay
>>oktay -Original Message- From: Philip Olson [mailto:[EMAIL PROTECTED]] Sent: Monday, May 07, 2001 2:43 PM To: [EMAIL PROTECTED] Subject: RE: [PHP] variable functions: empty/isset/unset invalid? Solved. empty, isset and unset are not functions, they are language contructs, which resu

RE: [PHP] variable functions: empty/isset/unset invalid?

2001-05-07 Thread Philip Olson
Solved. empty, isset and unset are not functions, they are language contructs, which results in the error. This makes sense, a workaround is creating functions like isEmpty (or something similar) and using them. I'll be submitting a future request soon ;) Thanks everyone, especially OpenSrc i

RE: [PHP] variable functions: empty/isset/unset invalid?

2001-05-07 Thread Johnson, Kirk
ent: Monday, May 07, 2001 11:45 AM > To: [EMAIL PROTECTED] > Subject: RE: [PHP] variable functions: empty/isset/unset invalid? > > > > I wish it were that easy. Also, I'm looking for words on WHY this > behavior exists. > > http://www.php.net/manual/en/function

RE: [PHP] variable functions: empty/isset/unset invalid?

2001-05-07 Thread Philip Olson
> > if ($foo{$var}) print 'worked.'; > > Kirk > > > -Original Message- > > From: Philip Olson [mailto:[EMAIL PROTECTED]] > > Subject: [PHP] variable functions: empty/isset/unset invalid? > > > > This does not work as expected (as

RE: [PHP] variable functions: empty/isset/unset invalid?

2001-05-07 Thread Johnson, Kirk
Change the parens around $var to curly braces: if ($foo{$var}) print 'worked.'; Kirk > -Original Message- > From: Philip Olson [mailto:[EMAIL PROTECTED]] > Subject: [PHP] variable functions: empty/isset/unset invalid? > > This does not work as expected (as

RE: [PHP] variable functions: empty/isset/unset invalid?

2001-05-07 Thread Altunergil, Oktay
$foo is a string not a PHP function which makes 'empty' a string and not a function/command. Am I missing something? oktay -Original Message- From: Philip Olson [mailto:[EMAIL PROTECTED]] Sent: Monday, May 07, 2001 1:04 PM To: [EMAIL PROTECTED] Subject: [PHP] variable functi

[PHP] variable functions: empty/isset/unset invalid?

2001-05-07 Thread Philip Olson
This does not work as expected (as I expect it at least) and gives the following error. This seems to result with use of empty(), isset(), and unset(), perhaps others : Call to undefined function: empty() When using : $foo = 'empty'; if ($foo($var)) print 'worked.'; Of course the follow