一、基础与函数
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"; }}
-----
bar();?>
空行填什么?
6、<?php
$a=1; $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
// :
class A
{
var $one = 1;
function show_one()
{
echo $this->one;
}
}
// :
include("");
---------
?>
补充程序,调用类输出1;
二、数字类型与变量
定义如下变量:
var $empty = '';
var $null = NULL;
php测试题 来自淘豆网m.daumloan.com转载请标明出处.