php - How can I send data to a specific port and ip using Yii2? -
how can send data specific port , ip using yii framework? want send string specific ip.
using php can send data using or post or whatever method using method:
<?php // change own values $ip = '127.0.0.1'; $port = 80; $location = ''; $url = "http://$ip:$port/$location"; // define data want send $params = http_build_query( array( 'name1' => $value1, 'name2' => $value2, // ... ) ); // set method send data $opts = array('http' => array( 'method' => 'get', // or post or put or delete 'content' => $params, 'header' => 'content-type: application/x-www-form-urlencoded\r\n' ) ); $context = stream_context_create($opts); //build http context // send data , capture response $response = file_get_contents($url.$params, false, $context);
Comments
Post a Comment