blob: 3a271b28f49c5a2f3095fc8c6f97b995553d1a7c [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
Andrey Andreev53b8ef52012-11-08 21:38:53 +020013This helper is loaded using the following code::
Derek Jones8ede1a22011-10-05 13:34:52 -050014
15 $this->load->helper('path');
16
17The following functions are available:
18
19set_realpath()
20==============
21
Andrey Andreev53b8ef52012-11-08 21:38:53 +020022.. php:function:: set_realpath($path, $check_existance = FALSE)
Derek Jones8ede1a22011-10-05 13:34:52 -050023
Andrey Andreev53b8ef52012-11-08 21:38:53 +020024 :param string $path: Path
25 :param bool $check_existance: Whether to check if the path actually exists
26 :returns: string
27
28This function will return a server path without symbolic links or
29relative directory structures. An optional second argument will
30cause an error to be triggered if the path cannot be resolved.
31
32Examples::
Derek Jones8ede1a22011-10-05 13:34:52 -050033
Andrey Andreevce707b42012-03-14 10:26:08 +020034 $file = '/etc/php5/apache2/php.ini';
Andrey Andreev53b8ef52012-11-08 21:38:53 +020035 echo set_realpath($file); // Prints '/etc/php5/apache2/php.ini'
Taufan Adityaf2915f22012-03-14 00:02:39 +070036
Andrey Andreevce707b42012-03-14 10:26:08 +020037 $non_existent_file = '/path/to/non-exist-file.txt';
Andrey Andreev53b8ef52012-11-08 21:38:53 +020038 echo set_realpath($non_existent_file, TRUE); // Shows an error, as the path cannot be resolved
39 echo set_realpath($non_existent_file, FALSE); // Prints '/path/to/non-exist-file.txt'
Taufan Adityaf2915f22012-03-14 00:02:39 +070040
Andrey Andreevce707b42012-03-14 10:26:08 +020041 $directory = '/etc/php5';
Andrey Andreev53b8ef52012-11-08 21:38:53 +020042 echo set_realpath($directory); // Prints '/etc/php5/'
Taufan Adityaf2915f22012-03-14 00:02:39 +070043
Andrey Andreevce707b42012-03-14 10:26:08 +020044 $non_existent_directory = '/path/to/nowhere';
Andrey Andreev53b8ef52012-11-08 21:38:53 +020045 echo set_realpath($non_existent_directory, TRUE); // Shows an error, as the path cannot be resolved
46 echo set_realpath($non_existent_directory, FALSE); // Prints '/path/to/nowhere'