可能重复:
将 ereg 表达式转换为 preg
<?php
$searchtag = "google";
$link = "http://images.google.com/images?hl=de&q=$searchtag&btnG=Bilder-Suche&gbv=1";
$code = file_get_contents($link,'r');
ereg("imgurl=http://www.[A-Za-z0-9-]*.[A-Za-z]*[^.]*.[A-Za-z]*", $code, $img);
ereg("http://(.*)", $img[0], $img_pic);
echo '<img src="'.$img_pic[0].'" width="70" height="70">'; ?>
我得到这个错误
已弃用:函数 ereg() 在第 5 行的 C:\Program Files\EasyPHP-5.3.8.1\www\m\img.php 中已弃用
已弃用:函数 ereg() 在第 6 行的 C:\Program Files\EasyPHP-5.3.8.1\www\m\img.php 中已弃用
preg_match() 函数给出此错误
警告:preg_match() [function.preg-match]:第 6 行 C:\Program Files\EasyPHP-5.3.8.1\www\m\img.php 中的分隔符不能是字母数字或反斜杠
警告:preg_match() [function.preg-match]:第 7 行 C:\Program Files\EasyPHP-5.3.8.1\www\m\img.php 中的分隔符不能是字母数字或反斜杠