powershell - 从Windows Powershell ISE运行PHP CLI

标签 powershell php

此问题与Windows PowerShell ISE中的美元符号“$” $有关。

我具有PHP CLI,并希望从Windows PowerShell ISE中的提示符运行一个划线员命令脚本。
php -r "$foo = 'foo';"
只需返回Parse error: parse error in Command line code on line 1,我就将其缩小到讨厌的美元符号,这在PowerShell中很重要。我能以某种方式逃脱吗?

我也试过
php -r '$foo = "foo";'
并得到
Notice: Use of undefined constant foo - assumed 'foo' in Command line code on line 1

最佳答案

是的,在美元符号前添加反引号:

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

关于powershell - 从Windows Powershell ISE运行PHP CLI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9604589/

相关文章:

php - Zend : Cannot get router working from Bootstrap. php

php - 在此上下文中,元素 li 不允许作为元素 div 的子元素。 (抑制来自该子树的更多错误。)

php - 如何在 MySQL 搜索结果中突出显示关键字

php - 通过 PHP 格式化 Excel 文件中的文本

powershell - 无法从空的.txt文件执行export-csv

powershell - 如何在powershell中复制名称中包含变量的文件?

powershell - -PipelineVariable 不适用于 Get-NetIPAddress

c# - 对 C# .NET 4.0 上 Powershell 的 System.Management 的引用不起作用

windows - 在 Windows 中删除符号链接(symbolic link)

php - 在 WooCommerce 中添加到购物车特定产品之前清空购物车