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;
* 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
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
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:
>
* 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}();
> //
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:
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 (http://www
>
> 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
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
>>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
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
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
>
> 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
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
$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
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
17 matches
Mail list logo