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 at
* 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't exist, so
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:
?php
function foo() {
echo In foo()br /\n;
}
class a {
var
I need to record the names of functions, and then use them later.
Recently I found the following example within the on-line documentation:
?php
function foo() {
echo In foo()br /\n;
}
$func = 'foo';
$func();// This calls foo()
?
then I supposed that it was easy to extend this concept to
* 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}();
//
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:
?php
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
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
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
$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 functions: empty
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 I expect it at least) and gives
-
From: Philip Olson [mailto:[EMAIL PROTECTED]]
Subject: [PHP] variable functions: empty/isset/unset invalid?
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
, 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/functions.variable-functions.php
?php
// works
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
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 results in the error. This makes sense, a workaround is creating
functions
:[EMAIL PROTECTED]]
Sent: 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/functions.variable
16 matches
Mail list logo