首页 > Web开发 > 详细

php类与对象简单操作

时间:2015-08-25 15:53:19      阅读:156      评论:0      收藏:0      [点我收藏+]
 1 <?php
 2 /*
 3  * Created on 2015-8-25
 4  *
 5  * To change the template for this generated file go to
 6  * Window - Preferences - PHPeclipse - PHP - Code Templates
 7  */
 8  class Type{
 9 
10     var $username;
11     public function getUserName(){
12 
13         return $this->username;
14 
15     }
16     public function setUserName($username){
17         $this->username = $username;
18 
19     }
20 
21  }
22  class Free{
23      private static $username;
24      public static function getUser(){
25          return Free::$username;
26      }
27      public static  function setUser($username){
28          Free::$username = $username;
29 
30      }
31 
32  }
33  $user = "link";
34  Free::setUser($user);
35  echo Free::getUser();
36  $type = new Type();
37  $type->setUserName("zhangming");
38  echo $type->getUserName();
39 ?>

初学php,望大家能多多纠正错误。


php类与对象简单操作

原文:http://www.cnblogs.com/assassin666/p/4757454.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!