note 106805 deleted from functions.anonymous by danbrown
| From: | danbrown@php.net | Date: | Tue, 13 Dec 2011 18:28:37 +0000 |
| Subject: | note 106805 deleted from functions.anonymous by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-185065@lists.php.net to get a copy of this message | ||
Note Submitter: jochenvandevelde at gmail dot com
----
It might be interesting to note that anonymous functions cannot be compared against eachother. A
comparison of anonymous functions will always return false.
<?php
$one = function()
{
$foo = 'bar';
$bar = $foo + 123;
return (string) $bar;
};
$two = function()
{
$foo = 'bar';
$bar = $foo + 123;
return (string) $bar;
};
$three = function($name)
{
$text = 'Hello '.$name;
$int = 945;
return array($text, $int);
};
var_dump(($one == $two)); // -> (bool) false
var_dump(($one === $two)); // -> (bool) false
var_dump(($one == $three)); // -> (bool) false
var_dump(($one === $three)); // -> (bool) false
?>