one day php. alomost all;

<?
namespace Test;
use \PhpProject\PhpApp as Other;
$u=new Other("ns test");
echo $u->GetUserName();
echo "annotation: use include, pls include \\ which is the common namespace, which need not to be declared as default \\";
echo "<br>";
echo __NAMESPACE__;
echo "<br><br><br><br>";
?>
<?
namespace PhpProject;
//php注释的写法
echo "above shows how to create php annotation<br>";
//php string 连写
$test="inner string";
echo "how are ".$test;
echo "how are:$test<br>";
global $test;
//php类的写法
$GLOBALS["a"]=121;
echo $GLOBALS["a"]."<br>";
 class PhpApp{
	function PhpApp($name){
		$this->self=$name;
        $this::__construct($name);
	}
    //below is alternate way to construct this class	
	// function __construct(){	
	// }
	public	function GetUserName(){
		return "how are you ".$this->self;
	}	
	public static $Version;
	private $self;
    var $pty="pty json";
}
final class WebApp extends PhpApp{
	public function GetUserName(){
		return "webapp".parent::GetUserName();
	}	
}
PhpApp::$Version="1.00";
$user=new PhpApp("ctor");
echo $user->GetUserName();
echo PhpApp::$Version;
$web=new WebApp("webapp");
echo $web->GetUserName();
 echo json_encode($user,1);
var_dump(json_encode($user));
interface IPhpApp{
    function ruin();
}
class MyPhp implements IPhpApp{
    function ruin(){
        echo "ruined";
    }
}
$m=new MyPhp();
$m->ruin();

 

posted @ 2015-12-20 18:35  calochCN  阅读(129)  评论(0编辑  收藏  举报