curl - How to write PHP code to execute two functions -
i have php script (for docker remote api), i'm using stopping container "remotely":
<?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) ?>
it works! have piece of code "stop" two docker containers, instead of one.
i thinking this:
$cid = trim(file_get_contents('cid')); $pid = trim(file_get_contents('pid'));
then how rest of code like, stop both of them?
switch part:
$url = "http://172.17.0.1:2375/containers/$cid/stop?t=5"; echo "$url\n"; echo httppost($url)
to this
$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);
that's how can basicly. there can create more complex structs.
Comments
Post a Comment