title: php require_once path difference between windows and linux
body: <p>I have a file located in my CakePHP root folder placed under a folder named cron. Path is:</p>
  
  <pre><code>c:/wamp/www/project/cron/daily.php
  </code></pre>
  
  <p>This file requires another file placed inside vendor folder of cake structure, like this:</p>
  
  <pre><code>require("/../vendors/phpMailer/class.phpmailer.php");
  </code></pre>
  
  <p>And i run this <strong>daily.php</strong> from task scheduler. This is the scenario in my development site.(Windows system). It works fine as expected. When i migrated the project to Ubuntu(production site), the <strong>require</strong> statement started causing issues; it cant find the required file. I made a small change there, like this:</p>
  
  <pre><code>require("../vendors/phpMailer/class.phpmailer.php"); &lt;= removed the preceding slash
  </code></pre>
  
  <p>And it worked. So my doubt is, is there a difference in how parent directory notation work in widows and Linux? If so, how can i overcome this? Its not feasible to remove a slash every time I move the project from my development site(windows) to production site (Linux).</p>
  
  <hr>
  
  <p>I tried this:</p>
  
  <pre><code> require("./../vendors/phpMailer/class.phpmailer.php");
  </code></pre>
  
  <p>It worked in linux. But gave "no such file directory" error in windows. It seems windows works only with:</p>
  
  <pre><code> require("/../vendors/phpMailer/class.phpmailer.php");
  </code></pre>
  
  <hr>
  
  <p><strong>Solution</strong></p>
  
  <p>From @TWCrap's help problem was solved as follows:</p>
  
  <pre><code>require(dirname(__FILE__)."/../vendors/phpMailer/class.phpmailer.php");
  </code></pre>
  
  <p>It works in both windows and linux(* tears of joy *). But in windows it produces path as:</p>
  
  <pre><code>C:\wamp\www\project\cron/../vendors/phpMailer/class.phpmailer.php
  </code></pre>
  
  <p>This path looks ugly and i hope it wont cause probs in future!</p>
  
  <p>-Thanks guys!</p>