Reply to Re: address of function or a virtual function

Your name:

Reply:


Posted by ZeldorBlat on 08/16/07 15:04

On Aug 16, 11:00 am, D_a_n_i_e_l <danwgr...@gmail.com> wrote:
> Is there some way to implement something like a virtual function or
> have something like a user defined function ? One solution I thought
> might work: store a reference (address) of a function in a variable
> and call it later if that variable has been set ? This seems to
> compile OK, but produces funny results. Is this outside the scope of
> php ?
>
> function testfn()
> {
> ...
> return $result;
>
> }
>
> $myfn = &testfn; // set it too the address of the function
> ...
> if (isset($myfn))
> $result = @$myfn(); // call my function

You can find out if a function exists using function_exists():

if(function_exists('testfn')
...

You can also call a function who's name is stored in a variable:

$myfn = 'testfn';
$result = $myfn(); //calls testfn()

Is that what you're trying to do?

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация