这一节没必要在这里练习代码了。反正怎么写都是错的,所谓的正确答案只有编写教程的人自己知道。
<?php
$str = "<ul>
<li>item 1</li>
<li>item 2</li>
</ul>";
//在这里补充代码,实现正则匹配所有li中的数据
preg_match_all('/(item 1)|(item 2)/',$str,$matches);
print_r($matches[0]);
<?php
$str = "<ul>
<li>item 1</li>
<li>item 2</li>
</ul>";
//在这里补充代码,实现正则匹配所有li中的数据
preg_match_all('/(item 1)|(item 2)/',$str,$matches);
print_r($matches[0]);
2016-06-04
class MyException extends Exception {
function getInfo() {
return '老师越来越不认真,越来越水了';
}
}
try {
throw new MyException('error');
} catch(Exception $e) {
echo $e->getInfo();
function getInfo() {
return '老师越来越不认真,越来越水了';
}
}
try {
throw new MyException('error');
} catch(Exception $e) {
echo $e->getInfo();
2016-06-04
<?php
class Car {
public $speed = 0;
//增加speedUp方法,使speed加10
public function speedUp() {
$this->speed += 10;
}
}
$car = new Car();
while ($car->speed<100){
$car->speedUp();
echo $car->speed.'<br/ >';
}
class Car {
public $speed = 0;
//增加speedUp方法,使speed加10
public function speedUp() {
$this->speed += 10;
}
}
$car = new Car();
while ($car->speed<100){
$car->speedUp();
echo $car->speed.'<br/ >';
}
2016-06-03
<?php
//创建一个关联数组,关联数组的键“orange”,值是“橘子”
$fruit = array(
'orange' => '橘子'
);
echo $fruit['orange'];
?>
赋值不可以用双引号“”,必须用单引号‘’。有报错。
//创建一个关联数组,关联数组的键“orange”,值是“橘子”
$fruit = array(
'orange' => '橘子'
);
echo $fruit['orange'];
?>
赋值不可以用双引号“”,必须用单引号‘’。有报错。
2016-06-03