I tried to manipulate var dump with a function inside a class, but failed. I received the error for the 2nd var dump. 1st dump was correctly shows a json result with the array. here is the error:
Fatal error: Call to undefined function updateValue() in ...
I do not understand where I got wrong in term of how instance works with function inside the class it created from. Aren't they suppose to able to execute the function inside the class since that is where it directly related with?
code:
class User {
private $dbh;
public function __construct($host,$user,$pass,$db) { ...};
public function getQs(){ ...};
public function updateValue($user){ ...};
}
$user = new stdClass;
$userParams = array('id' => 1, 'field' => 'questTitle', 'newvalue' => "Baaaaa");
$user = json_encode(array("user"=>$userParams));
var_dump($user);
$user = json_decode($user);
$userN=new User(...);
$dump=$userN.updateValue($user);
var_dump($dump);
NOTE: the ...
are there to hide sensitive information, they are actual code/variable that is valid in place.
Please help. Thanks
You need to use
->
instead of.
to call member functions..
as deceze mentioned is the string concatenation operator. So this codewould be equal to