Reputation: 2256
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
Reputation: 126712
Yes, add a backtick in front of the dollar sign:
php -r "`$foo = 'foo';"
Upvotes: 2