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,望大家能多多纠正错误。
相关文章推荐
- 之变量分离/引用(Scope in PHP)
- 之变量作用域(Scope in PHP)
- 之弱类型变量(Variables inside PHP)
- PHP的新特性finally
- 深入理解PHP原理之异常机制
- 关于PHP浮点数你应该知道的(All ‘bogus’ about the float in PHP)
- xampp版本和具体的php,mysql版本的对应
- 深入理解PHP原理之Session Gc的一个小概率Notice
- 注意PHP对字符串的递增运算
- php array_push()函数
- PHP浮点数的一个常见问题的解答
- PHP配置指令作用域说明(PHP_INI_PERDIR、PHP_INI_SYSTEM、PHP_INI_USER、PHP_INI_ALL)
- php clone()中的地址传递(&)
- Yii的事件和行为的区别和应用
- NRPE: Unable to read output的原因及排除
- 配置ftp服务
- yii2 表单使用方法
- php 解决和避免form表单重复提交的方法
- YII 1.0 发表文章用到的小物件
- URL重写 省略index.php