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
  if (empty($var)) print '$var is empty<br>';
  
  // works
  $foo = 'is_string';
  $var = 'abcdef';   
  if ($foo($var)) print '$var is a string<br>';
  
  // works
  $foo = 'strlen';
  $var = 'abcdef';
  if ($foo($var) > 5) print '$var is over 5 chars<br>';
  
  // doesn't work : Fatal Error : Call to undefined function: empty()
  // same with isset() and unset()
  $foo = 'empty';
  if ($foo($var)) print '$var is empty';
  
?>

In otherwords, only these few functions aren't working as "variable
functions" but result in a "Fatal Error" instead.  Why?


Regards,
Philip

On Mon, 7 May 2001, Johnson, Kirk wrote:

> 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 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.';
>  
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to