變態的面試題目:
1、第一題目答案:
<?php
$fd = fopen("/dev/fd/1","w");
fwrite($fd,"hello,world",20);
執行結果:
2、第二題目答案: php手冊例子有
$socket = stream_socket_server("tcp://0.0.0.0:8000", $errno, $errstr);
if (!$socket) {
echo "$errstr ($errno)<br />\n";
} else {
while ($conn = stream_socket_accept($socket)) {
fwrite($conn, 'The local time is ' . date('n/j/Y g:i a') . "\n");
fclose($conn);
}
fclose($socket);
}
3、第三題目答案:
4、第四題目答案:
5、第五題目答案:
6、第六題答案:
7、第七題答案:
php手冊例子