有趣的面试题目

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、第七题

https://www.php.net/manual/zh/function.stream-context-create.php

点赞

发表评论