您的位置:首页 > 编程语言 > PHP开发

php类与对象简单操作

2015-08-25 14:55 671 查看
<?php
/*
* Created on 2015-8-25
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
class Type{

var $username;
public function getUserName(){

return $this->username;

}
public function setUserName($username){
$this->username = $username;

}

}
class Free{
private static $username;
public static function getUser(){
return Free::$username;
}
public static  function setUser($username){
Free::$username = $username;

}

}
$user = "link";
Free::setUser($user);
echo Free::getUser();
$type = new Type();
$type->setUserName("zhangming");
echo $type->getUserName();
?>

初学php,望大家能多多纠正错误。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: