zoukankan      html  css  js  c++  java
  • php类与对象简单操作

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


    吾宁做一叶扁舟,始航于湖边,遨游于海上,浪迹于江中。
  • 相关阅读:
    自我介绍
    最大连通子数组求和
    敏捷开发方法综述
    第四周学习进度条
    时间日志和缺陷日志
    最大子数组2.0
    最大子数组1.0
    第三周学习进度条
    小学四则运算3.0
    单元测试
  • 原文地址:https://www.cnblogs.com/assassin666/p/4757454.html
Copyright © 2011-2022 走看看