Last active
May 15, 2016 13:36
-
-
Save insideone/b401baca09a67a3c802dfae405c0e894 to your computer and use it in GitHub Desktop.
PHP: webpath/syspath
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Получает имя файла относительно корня сайта | |
* @param string $syspath Полное имя файла | |
*/ | |
function syspath($webpath) | |
{ | |
return preg_match('~^('.$_SERVER['DOCUMENT_ROOT'].')~', $webpath) ? $webpath : $_SERVER['DOCUMENT_ROOT'].$webpath; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Получает имя файла относительно корня сайта | |
* @param string $syspath Полное имя файла | |
*/ | |
function webpath($syspath) | |
{ | |
return preg_replace('~^('.$_SERVER['DOCUMENT_ROOT'].')~', '', $syspath); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment