public function __call ($name,$args) {
if($name == 'speedDown'){
$this ->speed-=10;
}}
if($name == 'speedDown'){
$this ->speed-=10;
}}
2015-10-27
<?php
$str = '主要有以下几个文件:index.php, style.css, common.js';
//将目标字符串$str中的文件名替换后增加em标签
$pattern = '/主要有以下几个文件:(.*), (.*), (.*)/';
$replacement = '主要有以下几个文件:<em>$1</em>, <em>$2</em>, <em>$3</em>';
echo preg_replace($pattern,$replacement,$str);
$str = '主要有以下几个文件:index.php, style.css, common.js';
//将目标字符串$str中的文件名替换后增加em标签
$pattern = '/主要有以下几个文件:(.*), (.*), (.*)/';
$replacement = '主要有以下几个文件:<em>$1</em>, <em>$2</em>, <em>$3</em>';
echo preg_replace($pattern,$replacement,$str);
2015-10-27
<?php
$str = "<ul>
<li>item 1</li>
<li>item 2</li>
</ul>";
$pattern = '/<li>(.*?)<\/li>/i';
preg_match_all($pattern,$str,$matches);
print_r($matches[1]);
$str = "<ul>
<li>item 1</li>
<li>item 2</li>
</ul>";
$pattern = '/<li>(.*?)<\/li>/i';
preg_match_all($pattern,$str,$matches);
print_r($matches[1]);
2015-10-27
<?php
$subject = "my email is spark@imooc.com";
//在这里补充代码,实现正则匹配,并输出邮箱地址
$pattern = '/my email is (.*)/';
preg_match($pattern,$subject,$matches);
echo $matches[1];
$subject = "my email is spark@imooc.com";
//在这里补充代码,实现正则匹配,并输出邮箱地址
$pattern = '/my email is (.*)/';
preg_match($pattern,$subject,$matches);
echo $matches[1];
2015-10-27
public function start(){
self::speedUp();
return $speed;
}
静态方法也可以实现
self::speedUp();
return $speed;
}
静态方法也可以实现
2015-10-24
<?php
$str = '主要有以下几个文件:index.php, style.css, common.js';
//将目标字符串$str中的文件名替换后增加em标签
$b='/\w+\.\w+/i';
$c='<em>$0</em>';
$str=preg_replace($b,$c,$str);
echo $str;
$str = '主要有以下几个文件:index.php, style.css, common.js';
//将目标字符串$str中的文件名替换后增加em标签
$b='/\w+\.\w+/i';
$c='<em>$0</em>';
$str=preg_replace($b,$c,$str);
echo $str;
2015-10-23