<?php
class Foo {
public static function a() {
echo( "Foo::a()\n" );
}
public static function by_name() {
echo( "Foo::by_name()\n" );
}
public static function by_column(
$column,
$param
) {
echo( "Foo::by_column_" . $column . "(" . $param . ")\n" );
}
function __call( $name, $params ) {
$names = split( '[_]', $name );
if( $names[0] && $names[0] == "find" && $names[1] && $names[1] == "by" && $names[2] ) {
Foo::by_column( $names[2], $params[0] );
}
}
}
$cname = "Foo";
$cname::a();
$bname = "by_";
$dname = $bname . "name";
//$cname::$bname . "name"();
$cname::$dname();
$inst = new Foo;
$inst->find_by_session( "hoge" );
?>
こうやってみれば、スクリプトはオモロイかも…。
0 件のコメント:
コメントを投稿