Silliness that passed the last quarter hour of work today:
<?php
class foo {
public function foo(&$foo) {
$foo = create_function(
'$foo',
'echo "Hello, $foo.";'
);
}
}
new foo($foo);
$foo('foo');
Silliness that passed the last quarter hour of work today:
<?php
class foo {
public function foo(&$foo) {
$foo = create_function(
'$foo',
'echo "Hello, $foo.";'
);
}
}
new foo($foo);
$foo('foo');
version 1.1:
<?php
class foo {
private function __construct() {}
public static function foo(&$foo) {
$foo = create_function('$foo','echo "Hello, $foo.";');
}
}
foo::foo($foo);$foo('foo');
<?php #> 5.4
class foo{
static function newFoo( Closure $foo ){
$foo = $foo->bindTo( null,__CLASS__ );
return $foo;
}
static function parentFoo(){
return get_called_class();
}
}
$foo = foo::newFoo( function( $foo ){ echo "Hello, $foo! My name is ".static::parentFoo(); } );
$foo( 'Foo' );
edit
or...
<?php #> 5.4
class foo{
static function newFoo( Closure $foo ){
$foo = $foo->bindTo( null,__CLASS__ );
return $foo;
}
static function parentFoo(){
return get_called_class();
}
}
$foo = foo::newFoo( function()use( &$bar ){ echo "Hello, $bar! My name is ".static::parentFoo(); } );
$bar = 'Me';
$foo();
$bar = 'You';
$foo();
And for another layer of absurdity:
/foo:
<?php
class foo {
private function __construct() {}
public static function foo(&$foo) {
$foo = create_function('$foo','echo "Hello, $foo.";');
}
}
/foo.php:
require 'foo';foo::foo($foo);$foo('foo');
NogDog;11028123 wrote:And for another layer of absurdity
you mean, abstraction.
traq;11028125 wrote:you mean, abstraction.
Yeah, that's it: I knew it started with "abs...".
You people have foo much time on your hands...
laserlight;11028143 wrote:You people have foo much time on your hands...
Heh heh ... where's the "like" button? :p
laserlight;11028143 wrote:You people have foo much time on your hands...
They should be barred!
Bonesnap;11028151 wrote:They should be barred!
That's a really baz idea if you ask me!