Re: static functions and array_map - why not allowed?

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

 



Marc Weber wrote:
> 
> Why can't I use static functions in array_map?
> 
> Example:
> 
> <?php
> class Dummy
> {
>   static public function T($a)
>   {
>     echo "T called with $a\n";
>     return $a+2;
>   }
> }
> 
> function t($a)
> {
>   echo "t called with $a\n";
>   return $a*2;
> }
> 
> echo 'invoking Dummy::T works fine : ', Dummy::T(3),"\n";
> var_dump(array_map('t',array(1,2)));
> var_dump(array_map('Dummy::T',array(1,2)));


do it like this:

var_dump(array_map(array("Dummy","T"), array(1,2)));

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

-- 
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