zsh: bad math expression: operand expected at `'HTTP_HOST...'

Viewed 6517

I'm trying to run the following php from the terminal:

php -r "error_reporting(E_NONE); $_SERVER['HTTP_HOST'] = 'localhost';
require('./config/site.php'); 
echo json_encode(array('HOST' => DB_SERVER, 'USER' => DB_USERNAME, 'PASS' => DB_PASSWORD, 'NAME' => DB_DATABASE));"

And I'm getting the following error:

zsh: bad math expression: operand expected at `'HTTP_HOST...'

Escaping the = has no effect and escaping the [ gives a PHP parse error:

PHP Parse error: syntax error, unexpected '[', expecting identifier (T_STRING) in Command line code on line 1

What am I doing wrong here? How can I run the code above from terminal?

1 Answers
Related