Return to Snippet

Revision: 51572
at September 28, 2011 16:45 by cdohost


Initial Code
if (!function_exists('bugFixRequirePath'))
{
	function bugFixRequirePath($newPath)
	{
       		$stringPath = dirname(__FILE__);
       		if (strstr($stringPath,":")) $stringExplode = "\\";	else $stringExplode = "/";
       		$paths = explode($stringExplode,$stringPath);
       		$newPaths = explode("/",$newPath);
       		if (count($newPaths) > 0)
		{
			for($i=0;$i<count($newPaths);$i++) { if ($newPaths[$i] == "..") array_pop($paths); }
			for($i=0;$i<count($newPaths);$i++) { if ($newPaths[$i] == "..") unset($newPaths[$i]); }
			reset($newPaths);
			$stringNewPath = implode($stringExplode,$paths).$stringExplode.implode($stringExplode,$newPaths);
			return $stringNewPath;
		}
	}
}

Initial URL

                                

Initial Description
Bug Fix Required Path (Corrige o bug no caminho do arquivo)

Initial Title
PHP - Bug Fix Required Path

Initial Tags
php, path

Initial Language
PHP