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,望大家能多多纠正错误。