fork(1) download
  1. <?php
  2. $url = 'http://w...content-available-to-author-only...e.com/home/index.html';
  3.  
  4. $href = 'images/sunflower.png';
  5. preg_match('~^(\.{0,2}\/)+~', $href, $matches);
  6. if (substr_count($matches[0], '../')){
  7. echo 'Go up ' . substr_count($matches[0], '../') . ' directories';
  8. }
  9. else if (substr_count($matches[0], '/')){
  10. echo 'Base directory';
  11. }
  12. else {
  13. echo 'Relative directory';
  14. }
  15.  
  16.  
  17. ?>
Success #stdin #stdout #stderr 0.01s 20568KB
stdin
Standard input is empty
stdout
Relative directory
stderr
PHP Notice:  Undefined offset: 0 in /home/D8Z18C/prog.php on line 6
PHP Notice:  Undefined offset: 0 in /home/D8Z18C/prog.php on line 9