title: Checking for relative vs absolute paths/URLs in PHP
body: <p>I need to implement functions to check whether paths and urls are relative, absolute, or invalid (invalid syntactically- not whether resource exists). What are the range of cases I should be looking for?</p>
  
  <pre><code>function check_path($dirOrFile) {
      // If it's an absolute path: (Anything that starts with a '/'?)
          return 'absolute';
      // If it's a relative path: 
          return 'relative';
      // If it's an invalid path:
          return 'invalid';
  }
  
  function check_url($url) {
      // If it's an absolute url: (Anything that starts with a 'http://' or 'https://'?)
          return 'absolute';
      // If it's a relative url:
          return 'relative';
      // If it's an invalid url:
          return 'invalid';
  }
  </code></pre>