Uyarı: preg_match_all () [function.preg-match-all]: Bilinmeyen değiştirici 'g'

0 Cevap php

Hatalar:

Warning: preg_match_all() [function.preg-match-all]: Unknown modifier 'g' in /Users/julian/Sites/abc.php on line 23 Warning: preg_match_all() [function.preg-match-all]: Unknown modifier 'g' in /Users/julian/Sites/abc.php on line 23

İşte benim kod:

<?php

class Crawler {
protected $markup = ”;
    public function __construct($uri) {
        $this->markup = $this->getMarkup($uri);
    }
    public function getMarkup($uri) {
        return file_get_contents($uri);
    }
    public function get($type) {
        $method = "_get_links";
        if (method_exists($this, $method))
                return call_user_method($method, $this);
             }
    }
    protected function _get_images() {
        if (!empty($this->markup)){
            preg_match_all(htmlspecialchars("<img([^>]+)/>i"), $this->markup, $images);
            return $images[1];
    }
    }
    protected function _get_links() {
        if (!empty($this->markup)){
            preg_match_all(htmlspecialchars("<a([^>]+)>(.*?)</a>/i"), $this->markup, $links);
            return $links;
        }
    }
}
$crawl = new Crawler("http://google.com/");
$images = $crawl->get(‘images’);
$links = $crawl->get(‘links’);
echo $links;
?>

0 Cevap