add functions to a class

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

I tried to add functions to a class, but it doesn't seem to work. Here's an example:

<?
class Test {

 function Test () {
  $funcName = 'writeFoo';
  $$funcName = create_function ('', 'echo ("foo.\n");');
  $writeFoo ();
  $writeFoo2 = $writeFoo;
  $writeFoo2 ();
  $this->writeFoo = $writeFoo;
  $this->writeFoo ();
 }
}

$test = new Test ();
?>

This outputs:
foo.
foo.
PHP Fatal error: Call to undefined method Test::writeFoo() in ..../test.php on line 11


Both $writeFoo () and $writeFoo2 () are executed, so it principally works, but once used in the object, it doesn't work anymore.


Any idea how that is supposed to work?


Gratefully,
 Tsenle

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux