php传值给shell
php代码:
$param1 = "https://www.baidu.com";
$param2 = "https://www.csdn.net/";
system("./p_s.sh $param1 $param2");
shell代码:
#!/bin/bash
param1=$1
param2=$2
echo $param1;
echo $param2;
输出:
https://www.baidu.com
https://www.csdn.net/
shell传值给php
shell代码:
php /root/p--s/s_p.php 123 456
php文件路径
/root/p--s/s_p.php
php代码
$name=$argv[0];
$val1=$argv[1];
$val2=$argv[2];
echo $name."\n";
echo $val1."\n";
echo $val2."\n";
echo "123456789"."\n";
输出:
/root/p--s/s_p.php
123
456
123456789