|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2016-03-19 05:42 UTC] tuadmin at gmail dot com
Description:
------------
<?php
class myclass{
public $x;
public function __construct($string){
$this->x=$string;
}
public function show(){
echo "this message is {$this->x}";
}
}
$func = function (){
$this->show();
};
$class = new myclass('hi this is example for bug');
$x = Closure::bind($func,$class);
$x();
Test script:
---------------
<?php
class myclass{
public $x;
public function __construct($string){
$this->x=$string;
}
public function show(){
echo "this message is {$this->x}";
}
}
$func = function (){
$this->show();
};
$class = new myclass('hi this is example for bug');
$x = Closure::bind($func,$class);
$x();
Expected result:
----------------
this message is hi this is example for bug
Actual result:
--------------
Warning: Cannot bind an instance to a static closure in phar://var/www/test.phar/web.php on line 15
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 18:00:01 2025 UTC |
for semi-patch or temporal solution in stub-web embed use... <?php function __temporal__solution__(){ require 'web.php'; } __temporal__solution__();