天空是藍色的

          做好軟件為中國 #gcc -c helloworld.c -o helloworld.o //編譯目標文件 #gcc helloworld.o -o helloworld //編譯成可執行exe #helloworld //運行exe
          數據加載中……
          我用PHP寫了個類,封裝方法-POPO傳統的舊的PHP對象?
          class.people.php
          <?php
          class People{
              
          var $name;
              
          var $age;
              
          function People($name,$age){
                  
          $this->setName($name);
                  
          $this->setAge($age);
                  
              }
              
          function getName(){
                  
          return $this->name;
              }
              
          function setName($name){
                  
          $this->name = $name;
              }    
              
          function getAge(){
                  
          return $this->age;
              }
              
          function setAge($age){
                  
          $this->age = $age;
              }
              
          }
          ?>
          index.php調用這個類
          <?php
          require("class.people.php");
          $xiaoli = new People("",23);
          echo "His name is".$xiaoli->getName();
          echo "His age is".$xiaoli->getAge();
          ?>

          posted on 2005-12-27 14:36 bluesky 閱讀(668) 評論(1)  編輯  收藏 所屬分類: PHP

          評論

          # re: 我用PHP寫了個類,封裝方法-POPO傳統的舊的PHP對象? 2005-12-27 14:48 bluesky

          不知道有沒有private public 私有成員和公開的方法??
          還是變量拿來就直接賦值呢?
          代碼好亂啊~~
            回復  更多評論    
          主站蜘蛛池模板: 那坡县| 井研县| 象山县| 会昌县| 孙吴县| 夏河县| 晋江市| 莫力| 出国| 天镇县| 麻阳| 工布江达县| 双城市| 通辽市| 福泉市| 昌都县| 都兰县| 雅安市| 微山县| 秦皇岛市| 阳东县| 溧水县| 丁青县| 文山县| 临邑县| 辉县市| 白朗县| 郧西县| 河津市| 原阳县| 和静县| 巴彦淖尔市| 马边| 铜鼓县| 札达县| 西城区| 东海县| 丹东市| 房产| 永平县| 时尚|