note 115723 added to function.stream-socket-client

From: Date: Fri, 12 Sep 2014 20:29:46 +0000
Subject: note 115723 added to function.stream-socket-client
Groups: php.notes 
Request: Send a blank email to php-notes+get-200434@lists.php.net to get a copy of this message
If you only need to check a stream for data, you can use stream_get_content and strtr function. stream_get_content reads the remainder of a stream into a string. <?php $addr = gethostbyname('www.example.com'); $client = stream_socket_client("tcp://$addr:80", $errno, $errorMessage); if($client === false){ throw new UnexpectedValueException("Failed to connect: $errorMessage"); } fwrite($client, "GET / HTTP/1.0\r\nhost: 'www.example.com'\r\nAccept: */*\r\n\r\n"); $variable = stream_get_content($client); if(strstr($variable,'data your looking for')) echo "The data you are looking for is here"; else echo "data not found"; fclose($client); ?> ---- Server IP: 72.52.91.14 Probable Submitter: 128.248.5.129 ---- Manual Page -- http://php.net/manual/en/function.stream-socket-client.php Edit -- https://master.php.net/note/edit/115723 Del: integrated -- https://master.php.net/note/delete/115723/integrated Del: useless -- https://master.php.net/note/delete/115723/useless Del: bad code -- https://master.php.net/note/delete/115723/bad+code Del: spam -- https://master.php.net/note/delete/115723/spam Del: non-english -- https://master.php.net/note/delete/115723/non-english Del: in docs -- https://master.php.net/note/delete/115723/in+docs Del: other reasons-- https://master.php.net/note/delete/115723 Reject -- https://master.php.net/note/reject/115723 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#200434) next »