A have a variable with a -
. When I run my script I get Parse error: syntax error, unexpected '='
.
This is the following line:
$selected-text = $_POST['faco'] ;
How can I write this script without changing the variable name?
A have a variable with a -
. When I run my script I get Parse error: syntax error, unexpected '='
.
This is the following line:
$selected-text = $_POST['faco'] ;
How can I write this script without changing the variable name?
The "-" character is a reserved operator in PHP and can't be used in variable names. Use an underscore instead:
`$selected_text = $_POST['faco'];`
In PHP a valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*' (http://php.net/manual/en/language.variables.basics.php)