duangai1916 2010-05-27 08:03
浏览 8
已采纳

我们怎么称呼这个?

I'm wondering what do we call this kind of assignment.

<?php
class SimpleClass
{
    public $var1;
    public $var2;
    public $var3;

    public function SimpleClass()
    {
        $this->var1 = 'one';
        $this->var2 = 'two';
        $this->var3 = 'three';
    }
}

function test()
{
    $objSc = new SimpleClass();
    $objSc->var4 = 'WTF?!'; # <-- what do we call this?
    var_dump($objSc);
}

test();
?>

Better with references or links. Thanks in advance!

EDIT: I'm looking for a technical term for it... well, if we have.

  • 写回答

3条回答 默认 最新

  • doupu7651 2010-05-27 08:11
    关注

    I believe this is overloading.

    Overloading in PHP provides means to dynamically "create" properties and methods. These dynamic entities are processed via magic methods one can establish in a class for various action types.

    The overloading methods are invoked when interacting with properties or methods that have not been declared or are not visible in the current scope.

    PHP Manual reference here.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 用matlab 实现通信仿真
  • ¥15 按键修改电子时钟,C51单片机
  • ¥60 Java中实现如何实现张量类,并用于图像处理(不运用其他科学计算库和图像处理库))
  • ¥20 5037端口被adb自己占了
  • ¥15 python:excel数据写入多个对应word文档
  • ¥60 全一数分解素因子和素数循环节位数
  • ¥15 ffmpeg如何安装到虚拟环境
  • ¥188 寻找能做王者评分提取的
  • ¥15 matlab用simulink求解一个二阶微分方程,要求截图
  • ¥30 乘子法解约束最优化问题的matlab代码文件,最好有matlab代码文件