I try to store a string to a PHP variable. But it shows an error "Parse error: syntax error, unexpected '='" Here is the code
$page-title = "Home Page";
I try to store a string to a PHP variable. But it shows an error "Parse error: syntax error, unexpected '='" Here is the code
$page-title = "Home Page";
Do like this:
$page_title = "Home Page";
Replace $page-title = "Home Page";
with: $page_title = "Home Page";
The variable you used is wrong. PHP variables cant contain -
signs.
Your variable name is incorrect.
A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ ).
You can use it either $pageTitle
or $page_title
as your variable name
fore more detail refer php manual
you have use - subtraction sign in declaring variable that's why it cause an error you can check here how to declare php variableshow to declare php variables
try this
$page_title = "Home Page";