PHP magic methods example

前端 未结 1 450
小蘑菇
小蘑菇 2021-02-14 11:33

I have this question from the Zend PHP study guide and can\'t find a proper explanation...



        
相关标签:
1条回答
  • 2021-02-14 12:27

    Since __get() calls echo, some data is being outputted before the echo outside of the class gets called.

    Stepping through the first line with echo, this is how it gets executed:

    $m->a   "A" is concatenated
    ","     "," is concatenated
    $m->b   "b," is echoed, "B" is concatenated
    ","     "," is concatenated
    $m->c   "c," is echoed, "C" is concatenated
    "m"     "," is concatenated
    

    At this point, b,c, has already been echoed, and the string with the value of A,B,Cm is now displayed.

    0 讨论(0)
提交回复
热议问题