Here is my code:
<?php
public function __construct() {
getUsername();
}
public function getUsername() {
//blah blah blah
return "bobby";
}
?>
It does not work and it says this error:
Fatal error: Uncaught Error: Call to undefined function...
but if I call the function in my constructor like this: $this->getUsername();
it works. Why is that the case?
It cannot identify your method. We have to tell it to use getUsername()
method which is in this class like this $this->getUsername();
$this->
is for find in this class.
read this link
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