Anonymous user
Send an unknown method call: Difference between revisions
added php
m (oops lost section) |
(added php) |
||
Line 26:
return 42 + $x;
}
package main;
my $name = "foo";
Line 33:
=={{header|Perl 6}}==
<lang perl6>$object."$methname"(5)</lang>
=={{header|PHP}}==
<lang php><?php
class Example {
function foo($x) {
return 42 + $x;
}
}
$example = new Example();
$name = 'foo';
echo $example->$name(5), "\n"; // prints "47"
// alternately:
echo call_user_func(array($example, $name), 5), "\n";
?></lang>
=={{header|Python}}==
|