如何在powershell中使用3个参数调用PHP页面



下面是我的PS1代码调用PHP。但是我想知道如何用3个参数调用PHP页面,以及如何在PHP中获得它。

$workflow_id = 170
$task_num = 3
$next_script = 'testing.php'
$PhpExe  = "C:Adminbinphpphp7.4.26php.exe"
$PhpFile = "C:Adminwwwxpress"+$next_script+" "+$workflow_id+" "+$task_num
echo $PhpFile
$PhpArgs = '-f "{0}"' -f $PhpFile
$PhpOutput = & $PhpExe $PhpArgs 
echo $PhpOutput // could not open file. but the file is present in this path 

//testing.php

<?php include("commons/connection.php"); ?>
<?php
$workflow_id = $argv[1];
$task_num = $argv[2];    
$update_pass = "UPDATE workflow_details SET Status ='mm' where `Workflow_Number` = $workflow_id and Work_type = 'PrepWork' and Task_Number =  $task_num " ; 
$status_result=mysqli_query($con,$update_pass);
?>

我收到无法打开文件。运行ps1

从PowerShell调用PHP脚本的尝试在两个方面是有缺陷的:

  • $PhpArgs单个字符串,因此作为单个参数传递,而您需要将-f和PHP脚本文件名/路径作为单个参数传递。

  • 你没有传递任何参数给PHP脚本。

因此,按如下方式调用$PhpExe:

# Call script file $PhpFile with the values of $workflow_id and $task_num
# as arguments, and capture the output in variable $PhpOutput
$PhpOutput = & $PhpExe -f $PhpFile -- $workflow_id $task_num

相关内容

  • 没有找到相关文章

最新更新