class - Method name must be a string, error in PHP -
here code,
class tasks { public $parent; public function __construct($parent) { $this->parent = $parent; } public function get_task($parent) { return mysqli_query($db, "select task, status, created_at tasks parent '$parent' , user='$user_id'"); } } $project = new tasks("null"); print "<div class='project'>" . $project->$get_task() . "</div>";
i expect should pass "null" mysql_query , return result(s). error,
fatal error: method name must string
update: fix didn't make instances of class. instead passed value wanted function tasks::get_task(value-here)
.
replace
print "<div class='project'>" . $project->$get_task() . "</div>";
with
print "<div class='project'>" . $project->get_task() . "</div>";
(remove $ sign).
Comments
Post a Comment