so in php, you don't have define the field in a class first like java , is that correct??
in java you cannot say
public class javac {
int x;
int y;
public javaC() {
this.z = 3;
}
}
but in php can you say that?
class phpC {
$x;
$y;
public phpC() {
$this->z = "omg";
}
}
what is php's documentation on this? and what is the correct term for such behaviour, i dont think it is called adding field on the fly
You are correct.. You can assign a value to an uninitialized property in PHP. Java is strict and PHP is loosey goosey :)
The technical name for this is "overloading." Here is the documentation: http://php.net/manual/en/language.oop5.overloading.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With