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

The use of PHP monomorphism

WBOY
Release: 2016-08-20 08:47:21
Original
1021 people have browsed it
跳至 [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);
Copy after login
Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template