php - Troubleshooting "Delimiter must not be alphanumeric or backslash" error when changing ereg() to preg_match() -
possible duplicate:
converting ereg expressions 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">'; ?> and error
deprecated: function ereg() deprecated in c:\program files\easyphp-5.3.8.1\www\m\img.php on line 5
deprecated: function ereg() deprecated in c:\program files\easyphp-5.3.8.1\www\m\img.php on line 6
preg_match() functions give error
warning: preg_match() [function.preg-match]: delimiter must not alphanumeric or backslash in c:\program files\easyphp-5.3.8.1\www\m\img.php on line 6
warning: preg_match() [function.preg-match]: delimiter must not alphanumeric or backslash in c:\program files\easyphp-5.3.8.1\www\m\img.php on line 7
eregdeprecated. don't use it.- the
pregfunctions "perl regular expressions" meaning need have sort of beginning , end marker on regex./or#, non alpha-numeric fine.
for example, these work:
preg_match("/foo/u",$needle,$haystack); preg_match("#foo#i",$needle,$haystack); preg_match("@foo@",$needle,$haystack); preg_match("\$foo\$w",$needle,$haystack); // bad idea because `$` means // in regex valid anyway // also, need escaped since // i'm using " instead of ' but not:
preg_match("foo",$needle,$haystack); // no delimiter!
Comments
Post a Comment