ID:               41380
 Comment by:       judas dot iscariote at gmail dot com
 Reported By:      stosh1985 at gmail dot com
 Status:           Open
 Bug Type:         Documentation problem
 Operating System: Mac OS X
 PHP Version:      5.2.2
 New Comment:

http://php.net/manual/en/language.oop5.basic.php

"The default value must be a constant expression, not (for example) a
variable, a class member or a function call."

This is the expected behaviuor.. a lambda style function is not a
constant expression.


Previous Comments:
------------------------------------------------------------------------

[2007-05-12 20:51:28] stosh1985 at gmail dot com

Description:
------------
I am unable to store lambda-style function within object properties,
like I am with normal variables.  The below code does not work, neither
does calling $this->$method() or using call_user_func() with passing in
array($this, $this->method) for the callback.

Reproduce code:
---------------
<?php

class foo {
    public $method;

    function __construct() {
        $this->method = create_function('$a, $b', 'print $a . "\n" . $b
. "\n\n"; ');

        $this->method('a', 'b');
    }
}

$x = new foo();
$x->method('a', 'b');

?>

Expected result:
----------------
a
b

a
b


Actual result:
--------------
Fatal error: Call to undefined method foo::method


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=41380&edit=1

Reply via email to