Bitrix Site Manager

CMain::GetFileRecursive

mixed
CMain::GetFileRecursive(
 string file,
 mixed dir
)

The method GetFileRecursive searches for a file recursively up the folder hierarchy.

Parameters

ParameterDescription
file Name of the file.
dir Path to the folder from which the search is to be performed. If set to false, the search will start from the current folder.
Optional, false by default.

Return Values

Returns the path to the found file relative to the site root, or false otherwise.

Example



<?
// search for the file params.php up the folder hierarchy 
// starting from the current folder.
// if the file can be found, include it
include($_SERVER["DOCUMENT_ROOT"].$APPLICATION->GetFileRecursive("params.php"));
?>