protected function format($path)
    {
        //replace back slash with forward
        $path = str_replace('\\', '/', $path);

        //replace double forward slash with 1 forward slash
        $path = str_replace('//', '/', $path);

        //if there is a last forward slash
        if (substr($path, -1, 1) == '/') {
            //remove it
            $path = substr($path, 0, -1);
        }

        //if the path does not start with a foward slash
        //and the path does not have a colon
        //(this is a test for windows)
        if (substr($path, 0, 1) != '/' && !preg_match("/^[A-Za-z]+\:/", $path)) {
            //it's safe to add a slash
            $path = '/'.$path;
        }

        return $path;
    }
protected function format($path)
    {
        //replace back slash with forward
        $path = str_replace('\\', '/', $path);

        //replace double forward slash with 1 forward slash
        $path = str_replace('//', '/', $path);

        //if there is a last forward slash
        if (substr($path, -1, 1) == '/') {
            //remove it
            $path = substr($path, 0, -1);
        }

        //if the path does not start with a foward slash
        //and the path does not have a colon
        //(this is a test for windows)
        if (substr($path, 0, 1) != '/' && !preg_match("/^[A-Za-z]+\:/", $path)) {
            //it's safe to add a slash
            $path = '/'.$path;
        }

        return $path;
    }
protected function format ( $ path ) { //replace back slash with forward $ path = str_replace ( '\\' , '/' , $ path ) ; //replace double forward slash with 1 forward slash $ path = str_replace ( '//' , '/' , $ path ) ; //if there is a last forward slash if ( substr ( $ path , - 1 , 1 ) == '/' ) { //remove it $ path = substr ( $ path , 0 , - 1 ) ; } //if the path does not start with a foward slash //and the path does not have a colon //(this is a test for windows) if ( substr ( $ path , 0 , 1 ) != '/' && ! preg_match ( "/^[A-Za-z]+\:/" , $ path ) ) { //it's safe to add a slash $ path = '/' . $ path ; } return $ path ; }
Formats the path
1. Must start with forward slash
2. Must not end with forward slash
3. Must not have double forward slashes

@param *string $path The path to format

@return string
Formats the path 1 . Must start with forward slash 2 . Must not end with forward slash 3 . Must not have double forward slashes