简体   繁体   English

使用powershell执行带参数的php脚本

[英]Executing php script with parameter using powershell

I am trying to call the PHP file by, passing the request_number in the localhost URL using Powershell我正在尝试调用PHP文件,使用Powershell在本地主机 URL 中传递request_number

In HTML:在 HTML 中:

<a href='workflow_execution_progress.php?view_id=".$row['request_number']."' title='Click to see the progress of workflow'>

I referred to this link but not sure to modify it with parameters.我提到了这个链接,但不确定用参数修改它。 Executing php script on powershell 在powershell上执行php脚本

Update: My PowerShell更新:我的 PowerShell

$PhpExe  = "C:\path\to\php\install\dir\php.exe"
$PhpFile = "C:\path\to\script.php"
$PhpArgs = '-f "{0}"' -f $PhpFile  //args like view_id = 1 / 2 /3 (dynamically)
$PhpOutput = & $PhpExe $PhpArgs

You can use $argv to get an array of arguments passed to the script.您可以使用$argv获取传递给脚本的参数数组。

https://www.php.net/manual/en/reserved.variables.argv.php https://www.php.net/manual/en/reserved.variables.argv.php

php script.php arg1 arg2 arg3

<?php
var_dump($argv);
?>

array(4) {
  [0]=>
  string(10) "script.php"
  [1]=>
  string(4) "arg1"
  [2]=>
  string(4) "arg2"
  [3]=>
  string(4) "arg3"
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM