Home >php教程 >PHP源码 >The use of PHP monomorphism

The use of PHP monomorphism

WBOY
WBOYOriginal
2016-08-20 08:47:211022browse
跳至 [1] [全屏预览]
<?php
	/*
		作者 : shyhero
		邮箱 : shyhero@outlook.com
		Q  Q : 1757424878
	 */
	class Demo{
		private static $ob=null;

		private $name;
		private $age;

		private function __construct(){

		}

		public static function makeOb(){
			var_dump($a);
			if(self::$ob == null){
				$c = __CLASS__;
				self::$ob = new $c();
		 	}
			return self::$ob;
		}

		public function __set($tName,$value){
			$this -> $tName = $value;
		}
	}

	$a = Demo::makeOb();
	var_dump($a);
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn