title: Warning: preg_match_all() [function.preg-match-all]: Unknown modifier 'g'
body: <p>Errors:</p>
  
  <blockquote>
    <p>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</p>
  </blockquote>
  
  <p>Here is my code:</p>
  
  <pre><code>&lt;?php
  
  class Crawler {
  protected $markup = ”;
      public function __construct($uri) {
          $this-&gt;markup = $this-&gt;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-&gt;markup)){
              preg_match_all(htmlspecialchars("&lt;img([^&gt;]+)/&gt;i"), $this-&gt;markup, $images);
              return $images[1];
      }
      }
      protected function _get_links() {
          if (!empty($this-&gt;markup)){
              preg_match_all(htmlspecialchars("&lt;a([^&gt;]+)&gt;(.*?)&lt;/a&gt;/i"), $this-&gt;markup, $links);
              return $links;
          }
      }
  }
  $crawl = new Crawler("http://google.com/");
  $images = $crawl-&gt;get(‘images’);
  $links = $crawl-&gt;get(‘links’);
  echo $links;
  ?&gt;
  </code></pre>