今天介紹的是PHP的物件導向設計,看看就好XDDDD
宣告一個demo學生,然後進行自我介紹

<?php

class student {
  var stuid;
  var cname;
  function myname () {
    result = "Hi, My name is ".this->cname." , No. ".this->stuid;
    return result;
  }
}

demo = new student;
demo->stuid = "9527";                        //屬性
demo->cname = "HelloWorld";            //屬性
echo demo->myname();                      //方法

?>

 

undefined
PHP學習手冊

文章標籤
全站熱搜
創作者介紹
創作者 helloworld 的頭像
helloworld

Hello World

helloworld 發表在 痞客邦 留言(0) 人氣(1,607)