title: mkdir function throw exception 'File exists' even after checking that directory doesn't exist
body: <p>I stumbled upon a every strange behaviour with mkdir function in PHP. Below is an example of my simple code. </p>
  
  <pre><code>$filepath = '/media/static/css/common.css';
  if (!file_exists(dirname($filepath)))
  {
     mkdir(dirname($filepath), 0777, TRUE);
  }
  </code></pre>
  
  <p>'media' folder always exists. All folders into the 'media' folder have to be created. Before coping the common.css file I'd like to create a folder '/static/css'. </p>
  
  <p>mkdir OCCASIONALLY throw  exception "File exists". I tried to create a folder if it doesn't exist. 'File exists' is a common error, I assume, so the folder exists.</p>
  
  <p>I understand that there is a very little info I gave you and it is really strange error. Maybe you can give me any advice what I have to do and how I can test that bug and find the bottleneck.</p>
  
  <p>Server: CentOS release 6.4</p>
  
  <p>Thank you.</p>