一份PHP程序员面试题之笔试题及答案

发布时间:2020-04-20编辑:脚本学堂
本文为大家提供一份不错的php程序员的面试题,这里是笔试题部分,文章后面附有答案,大家可以作为参考。

二、答案部分
1. echo date('Y-m-d H:i:s', strtotime('-1 day'));
2. hello
3. landogok
4.

复制代码 代码示例:
$a = "abcd";
$b = "1234";
echo "初始化时 a=$a,b=$b<br>";
$a = $a . $b;
$b = strlen( $b );
$b = substr( $a, 0, (strlen($a) - $b ) );
$a = substr( $a, strlen($b) );
echo "交换后 a=$a,b=$b<br>";

5.

复制代码 代码示例:
(1)$sql = “select * from User where name='张三';
$result = mysql_query( $sql );
while( $row = mysql_fetch_array( $result, MYSQL_ASSOC ) ){
   echo $row[‘Name’];
}
(2) $sql = “select * from User order by ID asc limit 0,3”;
$result = mysql_query( $sql );
while( $row = mysql_fetch_array( $result, MYSQL_ASSOC ) ){
   echo $row[‘Name’];
}

6. javascript不支持二维数组定义,可以用arr[0] = new array()来解决
7. javascript代码如下:
 

<script>
function go2b(){
window.location = "b.html";
window.close();
}
setTimeout( "go2b()",5000 ); //5秒钟后自动执行go2b()
</script>

8.
(1)如下所示:
      略。因为懒得插入图片,如果想看结果可以把代码保存为html文件,再用浏览器打开查看。
(2)输出结果应为:
      姓名:
      电话:
      邮箱:
      地址:
因为表单是用post方式提交,但在a.php中却用get方式来读取,所以不会读到任何值。
9. 略
10.   a:visited { font-size: 14pt; color: red; }
11. 102 = 101-1
12. 答案为6,因为∏=3.1415926
13. 答案为2,规律为n=(n-2) – |(n-1)| ,n>=3