Iata cum puteti trimite date prin POST cu file_get_contents() la o pagina php si sa obtineti continutul returnat. Se foloseste file_get_contents() impreuna cu functia: stream_context_create().
Functia stream_context_create($opt) creaza si returneaza un continut Stream cu datele din $opt.
- $opt e un array cu array-uri asociative de forma: $arr['wrapper']['option'] = $value.
$postdata = http_build_query(['name'=>'some name', 'pass'=>'password']); //data to send 'name=some+name&pass=password' $opts = [ 'http' => [ 'method'=> 'POST', // GET or POST 'header' => 'Content-type: application/x-www-form-urlencoded'. PHP_EOL .'Content-Length: '. strlen($postdata). PHP_EOL, 'content' => $postdata ] ]; $send_data = stream_context_create($opts); $cnt = file_get_contents('http://domain.net/page.php', false, $send_data); //send data and get the returned content echo $cnt;- Functia http_build_query($arr) genereaza un sir URL-encoded cu datele din $arr, returneaza un sir de forma: 'key1=val1&key2=val2'.
<table></tr> <td>Cell-1</td><td>Cell-2</td> </tr></table>
h3 { background-image: url("image.jpg"); }
var arr = [1, "ab", "CoursesWeb.net"]; for(var i=0; i< arr.length; i++) { alert(arr[i]); };
$arr =["k1"=>"v1", "k2"=>"v2", "k3"=>"v3"); foreach($arr AS $k => $v) { echo "<br/>". $k ." - ". $v; }
He is so kind and meek. - El este atat de amabil si bland.
Tu padre tiene un carácter muy manso. - Tatal tau are un caracter foarte bland.