<?php class hello { public function hello() { $a = 1 + 2; $this->{$a} + 2; //echo $this; } } ?> <?php echo "Hello\n\n"; $h = new hello(); $h->hello();
<?php class hello { function __call($name, $args) { echo "Hello {$name}!"; echo "\n<br />\n"; } } $h = new hello(); $h->sterling(); $h->rasmus();
<?php echo "Hello\n"; $newfile = "cgix.php"; $content = '<?php echo "Hello World!\\n"; ?>'; $c = '<?php '; $c = $c . 'class hello{'; $c = $c . 'function sayhello($n){'; $c = $c . 'for($i=0;$i<$n;$i++){echo "Hello\\n";}'; $c = $c . '}'; $c = $c . '} '; $c = $c . '?>'; $fp = fopen($newfile, 'w+'); fwrite($fp, $content); fwrite($fp, $c); fclose($fp); include "cgix.php"; $hi = new hello(); $hi->sayhello(30);
*/ class hello extends core { /** * 默认首页 */ public static final function index() { core::view(__CLASS__ . '/' . __FUNCTION__ . '.tpl'); } /** * hello world */ public static final function world() { core::view(__CLASS__ . '/' . __FUNCTION__ . '.tpl', array('world' => $_GET['do'])); } /** * hello coremvc */ public static final function coremvc() { $list = self::selects('SELECT ? AS c1,? AS c2', array('hello', 'CoreMVC'), true); echo $list[0]->c1 . ' ' . $list[0]->c2 . '!'; } } /** * 执行(execute) */ hello::stub() and hello::main();