简体   繁体   中英

php: call python script with “*” as argument

I am trying to call a python script through php, but one of the arguments is getting passed as a reference? I want to pass "*" but when it gets to the python script, it turns into "attempt.php" which is my php files name. How could I fix this to pass just the "*" This is the code I send (with 3 variables and one of them is the "*" )

$python = `python test.py $a $b $c`;

* is a wildcard in the shell, you need to escape it. Use escapeshellarg .

$aesc = escapeshellarg($a);
$besc = escapeshellarg($b);
$cesc = escapeshellarg($c);
$python = `python test.py $aesc $besc $cesc`;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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