I am writing a program and have some code inside a string. This code is error free outside a string, however, when I put it inside a string, I get this error.
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in *directory and line number*
The errors occur on
$string = "if(isset($_POST['Submit']))";
Thanks in advance.
Use single quotes, and not double quotes:
this way, PHP will not try to interpolate the $_POST variable inside it. Otherwise, escape the $ character.