blob: 847f5a08bcfa15dc5cf7d02bc92264a9986ba7a9 [file] [log] [blame]
Derek Jones8ede1a22011-10-05 13:34:52 -05001###########
2Path Helper
3###########
4
5The Path Helper file contains functions that permits you to work with
6file paths on the server.
7
8.. contents:: Page Contents
9
10Loading this Helper
11===================
12
13This helper is loaded using the following code
14
15::
16
17 $this->load->helper('path');
18
19The following functions are available:
20
21set_realpath()
22==============
23
24Checks to see if the path exists. This function will return a server
25path without symbolic links or relative directory structures. An
26optional second argument will cause an error to be triggered if the path
27cannot be resolved.
28
29::
30
Andrey Andreevce707b42012-03-14 10:26:08 +020031 $file = '/etc/php5/apache2/php.ini';
32 echo set_realpath($file); // returns "/etc/php5/apache2/php.ini"
Taufan Adityaf2915f22012-03-14 00:02:39 +070033
Andrey Andreevce707b42012-03-14 10:26:08 +020034 $non_existent_file = '/path/to/non-exist-file.txt';
35 echo set_realpath($non_existent_file, TRUE); // shows an error, as the path cannot be resolved
36 echo set_realpath($non_existent_file, FALSE); // returns "/path/to/non-exist-file.txt"
Taufan Adityaf2915f22012-03-14 00:02:39 +070037
Andrey Andreevce707b42012-03-14 10:26:08 +020038 $directory = '/etc/php5';
39 echo set_realpath($directory); // returns "/etc/php5/"
Taufan Adityaf2915f22012-03-14 00:02:39 +070040
Andrey Andreevce707b42012-03-14 10:26:08 +020041 $non_existent_directory = '/path/to/nowhere';
42 echo set_realpath($non_existent_directory, TRUE); // shows an error, as the path cannot be resolved
43 echo set_realpath($non_existent_directory, FALSE); // returns "/path/to/nowhere"