Please refer to the following code {code ...}} the above is a piece of case code from the instructor. What I want to ask is, in the third line, why can't I directly write ($ options) in the function ~ For more information, see the following code:
Public function setOption ($ options) {$ vars = get_object_vars ($ this); foreach ($ options as $ key => $ val ){... ...}
}
The above is the instructor's case code.
In the third row, why cannot I write ($ options) directly in the ($ this) function)
Problem ~ Please kindly advise
Reply content:
See the following code
Public function setOption ($ options) {$ vars = get_object_vars ($ this); foreach ($ options as $ key => $ val ){... ...}
}
The above is the instructor's case code.
In the third row, why cannot I write ($ options) directly in the ($ this) function)
Problem ~ Please kindly advise
For example, setSun is the sun, and the real parameter ($ planet) is its satellite, and $ this is the whole galaxy. The earth is defined as a member of the Milky Way. We can use $ this-> earth to find it. Assign it to $ planet, and the Earth is surrounded by the sun. Similarly, $ this-> mars = $ planet, mars is surrounded by the sun. However, the sun has eight satellites. We should first use get_object_vars ($ this) to list all the stars in the Milky Way, and find these eight columns as arrays and assign them to $ planet, so setSun can run as the solar system.
$ This refers to the current class. You can print it out in var_dump ($ this. And $ options are two different things.