Rel2Abs
string
Rel2Abs(
string cur_dir,
string rel_path
);
The function returns path relative to the specified cur_dir directory. If rel_path is empty, the function returns false. If rel_path is the absolute path (i. e. starts from "/" or has the "C:\" type), the cur_dir parameter is ignored. If a pull up of the rel_path is attempted via "../" for the path to be higher than root, the function blocks this attempt by deleting all intermediary pull ups. For example: by request /test/. ./. ./test.php
it returns /test/test.php
.
Function parameters
Parameter | Description |
---|---|
cur_dir | Directory relative to which the rel_path is specified. |
rel_path | Relative path. |
Examples of use
<?
echo Rel2Abs("/site/", "/temp/index.php"); // /temp/index.php
echo Rel2Abs("/site/", "temp/index.php"); // /site/temp/index.php
echo Rel2Abs("/site/temp/", "../index.php"); // /site/index.php
echo Rel2Abs("/site/temp/", "../. ./index.php"); // /index.php
?>
© «Bitrix24», 2001-2024