When using realpath (and similar functions) remember that PHP will take in to account open_basedir restrictions. So, if you do something like:
<?php
// test.php in httpdocs folder
$path = realpath(dirname(__FILE__) . '/../application');
?>
where your open_basedir setting is set to the httpdocs folder and tmp, this will return false. You must set it to the level above (or off) for this to work.