UrlGenerator::getRelativePath()

static string getRelativePath(string $basePath, string $targetPath)

Returns the target path as relative reference from the base path.

Only the URIs path component (no schema, host etc.) is relevant and must be given, starting with a slash. Both paths must be absolute and not contain relative parts. Relative URLs from one resource to another are useful when generating self-contained downloadable document archives. Furthermore, they can be used to reduce the link size in documents.

Example target paths, given a base path of "/a/b/c/d": - "/a/b/c/d" -> "" - "/a/b/c/" -> "./" - "/a/b/" -> "../" - "/a/b/c/other" -> "other" - "/a/x/y" -> "../../x/y"

Parameters

string $basePath The base path
string $targetPath The target path

Return Value

string The relative target path
doc_Symfony
2016-10-28 06:36:04
Comments
Leave a Comment

Please login to continue.