Home >Backend Development >PHP Tutorial >php 类 完整例子

php 类 完整例子

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-23 14:28:501011browse

文件目录:

--index.php

--php

  --data_info.php

index.php

这里要require_once类所在的php文件

<?phprequire_once('./php/data_info.php');    $oneData=new user;    $oneData->setName("username");    $oneData->setPassword("password");    echo $oneData->getName();    echo $oneData->getPassword();?>

data_info.php

<?phpclass user{	var $name;	var $password;		public function __construct(){			}		public function setName($name){		$this->name=$name;	}	public function getName(){		return $this->name;	}	public function setPassword($password){		$this->password=$password;	}	public function getPassword(){		return $this->password;	}		function __destruct(){			}}

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
Previous article:PHP 读取网页文件Next article:CentOS6 编译PHP 5.3.8