扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
class Something { // In OOP classes are usually named starting with a cap letter. var $x; function setX($v) { // Methods start in lowercase then use lowercase to seprate // words in the method name example getValueOfArea() $this->x=$v; } function getX() { return $this->x; } } ?> |
$obj = new Something; |
$obj->setX(5); $see = $obj->getX(); |
class Another extends Something { var $y; function setY($v) { // Methods start in lowercase then use lowercase to seperate // words in the method name example getValueOfArea() $this->y=$v; } function getY() { return $this->y; } } ?> |
$obj2=new Another; $obj2->setX(6); $obj2->setY(7); |
class Something { var $x; function Something($y) { $this->x=$y; } function setX($v) { $this->x=$v; } function getX() { return $this->x; } } ?> |
$obj=new Something(6); |
function Something($x="3",$y="5") |
$obj=new Something(); // x=3 and y=5 $obj=new Something(8); // x=8 and y=5 $obj=new Something(8,9); // x=8 and y=9 |
function Another() { $this->y=5; $this->Something(); //explicit call to base class constructor. } ?> |
class Myclass { function Myclass() { $name="Myclass".func_num_args(); $this->$name(); //Note that $this->$name() is usually wrong but here //$name is a string with the name of the method to call. } function Myclass1($x) { code; } function Myclass2($x,$y) { code; } } ?> |
$obj1=new Myclass(1); //Will call Myclass1 $obj2=new Myclass(1,2); //Will call Myclass2 |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者