CodeIgniter User Guide Version 1.6.3

Path Helper

The Path Helper file contains functions that permits you to work with file paths on the server.

Loading this Helper

This helper is loaded using the following code:


The following functions are available:


Checks to see if the path exists. This function will return a server path without symbolic links or relative directory structures. An optional second argument will cause an error to be triggered if the path cannot be resolved.

$directory = './../../etc/passwd';
echo set_realpath($directory);
// returns "/etc/passwd"

$non_existent_directory = './../../path/not/found';
echo set_realpath($non_existent_directory, TRUE);
// returns "/path/not/found"

echo set_realpath($non_existent_directory, FALSE);
// returns an error, as the path could not be resolved