I have access to an Ubuntu server with PHP 7.0. I can run the following code without any problems:
php -r "echo 'hello world';"
But when I add an assignment operator like this:
php -r "echo 'hello world'; $t = 'hello world';"
I get the following error:
PHP Parse error: syntax error, unexpected '=', expecting end of file in Command line code
I just realized while typing this question that this is probably happening because the shell is trying to evaluate $t
. Is there anyway to make it not evaluate $t
? The reason I ask is because the code will contain single quotes. I suppose the simple solution would be to change the single quotes in the code to double quotes but if there is a way to do it without altering the code, it might be useful to know.