I have two classes memberdao and member class .I am creating an object of memberdao class inside member class .here is my code
require_once('/../dao/memberdao.class.php');
class Member
{
public $objMemberDao= new MemberDao();
}
but it gives an error Parse error: syntax error, unexpected T_NEW in C:\xampp\htdocs\membership\lib\member.class.php on line 9. I am new in php so please help
Syntax Error – This error is caused by an error in the PHP structure when a character is missing or added that shouldn't be there. Unexpected – This means the code is missing a character and PHP reaches the end of the file without finding what it's looking for.
Parse Error (Syntax) Parse errors are caused by misused or missing symbols in a syntax. The compiler catches the error and terminates the script. Parse errors are caused by: Unclosed brackets or quotes. Missing or extra semicolons or parentheses.
A parse error: syntax error, unexpected appears when the PHP interpreter detects a missing element. Most of the time, it is caused by a missing curly bracket “}”. To solve this, it will require you to scan the entire file to find the source of the error.
you cannot initialize new objects there. you must do it in the __construct function;
require_once('/../dao/memberdao.class.php');
class Member
{
public $objMemberDao;
public function __construct()
{
$this->objMemberDao= new MemberDao();
}
}
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