【发布时间】:2019-04-19 09:36:38
【问题描述】:
当我执行命令时显示错误$sessionId 未定义,当我定义$sessionId =''; 时显示错误:
取消定义变量 $_
虽然此命令在 powershell 中完美运行。 请指导我。
shell_exec("C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -ExecutionPolicy Bypass -NoProfile -InputFormat none -command $sessionId = ((quser /server:DC | Where-Object { $_ -match $userName }) -split ' +')[2]< NUL");
【问题讨论】:
-
$_是特定于 powershell 而不是 PHP 变量吗?如果是,那么您需要将其转义,因为$_将被视为双引号字符串中的 PHP 变量。试试\$_。 -
$_ 是特定于 powershell 的。先生,我试过 \$_ 但没有用。
标签: php powershell