Milo LaMar
Milo LaMar

Reputation: 2256

Run PHP CLI from Windows Powershell ISE

This question is regarding dollar signs "$" $ in Windows PowerShell ISE.

I have PHP CLI and want to run one liner command scripts from the prompt in Windows PowerShell ISE.

php -r "$foo = 'foo';"

Just returns Parse error: parse error in Command line code on line 1 and I've narrowed it down to the pesky dollar sign which is significant in PowerShell. Can I escape it somehow?

I also tried

php -r '$foo = "foo";'

and get

Notice: Use of undefined constant foo - assumed 'foo' in Command line code on line 1

Upvotes: 1

Views: 1119

Answers (2)

Shay Levy
Shay Levy

Reputation: 126712

Yes, add a backtick in front of the dollar sign:

php -r "`$foo = 'foo';"

Upvotes: 2

Andrey Marchuk
Andrey Marchuk

Reputation: 13483

This is what you need:

"`$foo = 'foo';"

Upvotes: 1

Related Questions