sam 的个人资料>>> 這也將會過去 <<<照片日志列表 工具 帮助
9月25日

mix-in ?

<?php

	//test.php
	require_once(dirname(__FILE__) . '/Person.php');
	//test
	$thePerson = new Person("nobody");
	$thePerson->say(" I am here!");
	$thePerson->toSay(" Are you All Right!");
	$thePerson->hello("I" , 'am', 'ok', '!');
?>


 
<?php
//Person.php
class Person {
	private $name; 

	function __construct($name=null)
	{
		if($name) {
			$this->name = $name;
		}
	} 

	function say($msg)
	{
		include(dirname(__FILE__) . '/module_say.php');
	} 

	function statement($msg)
	{
		return include(dirname(__FILE__) . '/module_statement.php');
	} 

	function toSay($msg)
	{
		echo($this->statement($msg));
	}

	function __call($name, $args)
	{
		$file = dirname(__FILE__) . '/module_' . $name . '.php';
		if(file_exists($file)) {
			return include($file);
		}
	}


} // class end 
?>
  


<?php
//file:module_hello.php
//like some class block
//class someClass {
////like some function block
////function hello($I, $am, $ok, $end) {
		////list($name,$args) = func_get_args(); //no need;Just show!
		list($I, $am, $ok, $end) = $args;

		$msg = sprintf("%s %s %s %s",
			$I, 
			$am,
			$ok,
			$end
		);
		echo($this->statement($msg));
////} //end function
//} //end class
?>

<?php
//file:module_say.php
//like some class block
//class someClass {
////like some function block
////function say($msg) {
	echo($this->name . ' say : [ ' . $msg . ' ] '  . "
\n"); ////} //end function //} //end class
?> <?php //file: module_statement.php //like some class block //class someClass { ////like some function block ////function statement($msg) { $rtn = $this->name . ' say : [ ' . $msg . ' ] ' . "
\n"; return $rtn; ////} //end function //} //end class ?>
9月15日

線上教學

Online Training Library® »
 
Online Training Library® » Microsoft »