如何编写PHP代码来执行两个函数

我有这个PHP脚本(用于Docker远程API),我用它来“远程”停止一个容器:

<?php $cid = trim(file_get_contents('cid')); echo "$cid\n"; function httpPost($url) { $ch = curl_init(); curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); curl_setopt($ch,CURLOPT_POST, true); $output=curl_exec($ch); curl_close($ch); return $output; } $url = "http://172.17.0.1:2375/containers/$cid/stop?t=5"; echo "$url\n"; echo httpPost($url) ?> 

有用! 但我想要这段代码“停止” 两个docker集装箱,而不是只有一个。

我在想这样的事情:

 $cid = trim(file_get_contents('cid')); $pid = trim(file_get_contents('pid')); 

那么代码的其余部分是怎么样的,这样我们就可以停止这两个呢?

切换此部分:

 $url = "http://172.17.0.1:2375/containers/$cid/stop?t=5"; echo "$url\n"; echo httpPost($url) 

对此

 $url1 = "http://172.17.0.1:2375/containers/$cid/stop?t=5"; $url2 = "http://172.17.0.1:2375/containers/$pid/stop?t=5"; echo httpPost($url1); echo httpPost($url2); 

这就是你可以基本做到这一点。 可以创build更复杂的结构。