search

Home  >  Q&A  >  body text

, where did the code I wrote go wrong? Why can't Peter be displayed?

image.pngimage.pngFollowing the teacher step by step, why does the teacher’s final running result peter appear, but I did not report an error, but the browser does not display the word peter. image.png

离开水的鱼离开水的鱼1522 days ago1245

reply all(3)I'll reply

  • 123

    1232020-11-24 11:41:14

    __construst () The constructor must be double underlined. Most magic methods are like this

    reply
    2
  • 行走

    double underline

    行走 · 2020-11-24 12:27:24
  • 小幸运?

    小幸运?2020-11-24 11:40:25

    Print $obj to see if the data is correct

    // 1. Check whether the class exists

    var_dump( class_exists('Staff') );// 2. Check whether the attribute exists

    var_dump( property_exists('Staff', 'name') );// 3. Get all properties of 1 in the class

    var_dump( get_class_vars('Staff') );// 4 . Get all attributes in the object

    $a = new Staff;

    var_dump( get_object_vars($a) );// 5. Get all methods in the class

    var_dump( get_class_methods('Staff') );// 6. Get the class name of the object

    var_dump( get_class($a) );

    reply
    1
  • Cancelreply