Saving a curl response into a php variable -


i trying access ec2's public hostname inside instance.

i run command

curl http:// 169 254.169.254/latest/meta-data/public-hostname 

inside php script , save response variable. how can this?

you can this

<?php   //url of targeted site   $url = "http://www.yahoo.com/";   $ch = curl_init();    // set url , other appropriate options   curl_setopt($ch, curlopt_url, $url);   curl_setopt($ch, curlopt_header, 0);   curl_setopt($ch, curlopt_returntransfer, true);    // grab url , pass browser    $output = curl_exec($ch);    //echo $output;  // close curl resource, , free system resources   curl_close($ch);   ?>   

the $output variable contains response.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -