पीएचपी fsockopen () समारोह
उदाहरण
fsockopen() उदाहरण:
<?php
$fp = fsockopen("www.w3schools.com", 80, $errno, $errstr, 20);
if (!$fp) {
echo "$errstr ($errno)<br>";
} else {
$out = "GET /
HTTP/1.1\r\n";
$out .= "Host: www.w3schools.com\r\n";
$out
.= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
while
(!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}
?>
परिभाषा और उपयोग
fsockopen() फ़ंक्शन एक इंटरनेट या यूनिक्स डोमेन सॉकेट कनेक्शन खोलता है।
वाक्य - विन्यास
fsockopen(hostname, port, errno, errstr, timeout)
पैरामीटर मान
Parameter | Description |
---|---|
hostname | Required. Specifies a hostname (like "www.w3schools.com"). ssl:// or tls:// works over TCP/IP to connect to the remote host |
port | Optional. Specifies the port number. Use -1 for transports that do not use ports, like unix:// |
errno | Optional. Specifies the system level error number |
errstr | Optional. Specifies the error message as a string |
timeout | Optional. Specifies the connection timeout (in seconds) |
टेक्निकल डिटेल
प्रतिलाभ की मात्रा: | एक फ़ाइल पॉइंटर जिसका उपयोग अन्य फ़ाइल फ़ंक्शंस (जैसे fgets (), fwrite (), fclose ()) के साथ किया जा सकता है। विफलता पर FALSE। |
---|---|
पीएचपी संस्करण: | 4.0+ |
पीएचपी नेटवर्क संदर्भ