php测试题.doc一、基础与函数
1、 $expression=false
<?php
if ($expression) {
?>
〈strong>This is true. </strong〉
<?php
} else {
?>
〈strong>This is false. </strong>
<?php
}
?>
显示什么?
2、 <?php
$foo 二'Bob';
$bar 二 &$foo;
$bar 二 〃My name is $bar〃;
echo $bar; echo $foo;?>
输出什么?
3、 <?php
$a = array( a 二〉 apple , b =/ banana 丿;
$b 二 array( a 二〉pear , b 二〉 strawberry , c 二〉 cherry ;; $c = $a + $b;
var_dump($c);?>
输出什么? (var_dump ()输出数组的结构)
4、 <?php
$a 二"Hello “;
$b = $a . "World!〃;
echo $b;?>
输出什么?
5、 <?php
function foo() {
function bar () {
echo 〃I don't exist until foo() is called. \n,z; }}
bar () ;?> 空行填什么?
6、 <?php
$a=l; $b=2;
Function Sum() { -- $a, $b;
$b=$a+$b;
}
Sum();
Echo $b;
?>
如果输出3,横线填什么?
7、 <?php
$i=0;
Switch($i) {
Case 0: Print “0” ;
Case 1: Print “1” ;
Case 2: Print “2“;
}
?>
输出什么?
8、 <?php
$i=0;
Do{
Print $i;
}while($i>0);
?>
输出什么?
9、 <?php
function add_some_extra(&$string)
{
$string . = ' and something extra. }
$str =,This is a string,'; add_some_extra($str);
echo $str;
?>
输出什么?
10、 <?php
// classa. inc:
class A
{
var $one 二 1;
function show_one()
{
echo $this->one;
}
}
// pagel・php:
include (,zclassa. inc");
?>
补充程序,调用类输出1;
二、数字类型与变量
定义如下变量:
var $empty 二'';
var $null
=NULL;
var $bool
二 FALSE;
var $notSet;
var $array
=array ()
1、 $empty的数据类型是什么?
A、 string B> boolean C、 array D、 null
2、 $x 二 e
php测试题 来自淘豆网m.daumloan.com转载请标明出处.