title: How to check if scandir() returns any error or warning?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/746672/check-whether-a-directory-exists-in-php">Check whether a Directory Exists in PHP</a>  </p>
  </blockquote>
  
  
  
  <p>I am trying scandir() to check contents of directories and sending path parameter using javascript and trying to load the contents in #container div:</p>
  
  <pre><code>$("#container").load("fetch_images.php?path="+pathvariable);
  </code></pre>
  
  <p>in fetch_images.php I am trying <code>scandir($_GET['pathvariable'])</code> to scan the elements of given directory. My problem is if proper path is not supplied using $_GET['pathvariable'] the page is showing some warning and error.</p>
  
  <p>trying to scan like <code>$files_dir_results = scandir($path);</code> and using <code>foreach()</code> to display all results of the array.</p>
  
  <p>I don't want to show any kind of warning or error on output page. I know I can disable PHP warning but I will prefer any better option.</p>
  
  <p>I don't know how to check if scandir() is returing any error or warning. thanks.</p>