fsockopen.php3

来自「linux操作系统中 php 核心编程所有例程 都是一些很不错的案例」· PHP3 代码 · 共 33 行

PHP3
33
字号
<?
	// tell browser not to render this
	header("Content-type: text/plain");

	// try to connect to Web server
	$connection = fsockopen("www.clearink.com", 
		80, &$error_number, &$error_description);

	if($connection)
	{
		// set non-blocking mode
		set_socket_blocking($connection, false);

		// set how long to wait
		set_socket_timeout($connection, 60);

		// tell server we want root document
		fputs($connection, "GET / HTTP/1.0");
		fputs($connection, "\r\n\r\n");

		// get the output
		fpassthru($connection);
		fclose($connection);
	}
	else
	{
		// $connect was false
		print("An error occurred!<BR>\n");
		print("Number: $error_number<BR>\n");
		print("Description: $error_description<BR>\n");
	}
?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?