您的位置:首页 > 职场人生

php面试(笔试部分)

2009-11-04 08:00 337 查看
普通PHP程序员笔试题
1. 用PHP打印出前一天的时间,打印格式是2007年5月10日 22:21:21
2. PHP代码如下:
$a="hello";
$b=&$a;
unset($b);
$b="world";
echo $a;
其结果是?
3. PHP代码如下:
$str="cd";
$$str="landog";
$$str.="ok";
echo $cd;
其结果是?
4. 用PHP写一段代码,实现不使用第3个变量,交换$a、$b的值,$a、$b的初始值自己定。
5. 根据题目要求,用PHP写出代码。
表名User
ID Name Tel Content Date
1 张三 13333663366 大专毕业 2006-10-11
3 张三 13612312331 本科毕业 2006-10-15
5 张四 020-5566556 中专毕业 2006-10-15
4 王五 13521212125 大专毕业 2006-12-25
2 …………
6 …………
假设数据库连接如下:
$mysql_db=mysql_connect("local","root","pass");
@mysql_select_db("DB",$mysql_db);
(1)查询出所有Name等于“张三”的记录,并输出。
(2)按ID升序查询,只返回排序后的前3条记录,并输出。
6. javascript能否定义二维数组,如果不能你如何解决?
7. 假设a.html和b.html在同一个文件夹下面,用javascript实现当打开a.html五秒钟后,自动跳转到b.html。
8. 有两个文件a.html和a.php,代码如下:
a.html
<html>
<head>
<meta http-equiv=Content-Type content=text/html;charset=utf-8>
<title>PHP程序员面试</title>
</head>
<body>
<center>
<form method="post" action="a.php">
<table border="1">
<tr>
<td align="right">姓名:</td>
<td align="left"><input type="text" ></td>
</tr>
<tr>
<td align="right">电话:</td>
<td align="left"><input type="text" ></td>
</tr>
<tr>
<td align="right">邮箱:</td>
<td align="left"><input type="text" ></td>
</tr>
<tr>
<td align="right">地址:</td>
<td align="left"><input type="text" ></td>
</tr>
<tr>
<td align="center" colspan="2">
<input type="submit" value="提交">
<input type="reset" value="重填">
</td>
</tr>
</table>
</form>
</center>
</body>
</html>
a. php
<?php
$user_name = $_GET['user_name'];
$user_tel = $_GET['user_tel'];
$user_email = $_GET['user_email'];
$user_add = $_GET['user_add'];
echo "用户名:$user_name<br>电话:$user_tel<br>邮箱:$user_email<br>地址:$user_add<br>";
?>

(1)请画出a.html在浏览器的显示效果图。
(2)在a.html中输入:用户名=张三,电话=020-38259977,邮箱=sunrising@srtek.cn,地址=广州升瑞,按提交按钮后输出结果是?
9. 你是否使用过版本控制工具,如果有,请简要说明。
10. 利用CSS样式表定义已访问的超链接字体大小为14pt,颜色为red。
11. 移动任意一位数或符号,使等式成立, 102 = 101-1。注:是移动不是交换,等号不能分开。
12. 规律题,3、1、4、1、5、9、2、( ), 请按照规律在括号内写出下一表达式。
13. 规律题,5、8、-3、5、-2、3、-1、( ),请按照规律在括号内写出下一表达式。

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
答案:

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 > $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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: