UCE Docs / path_real

Signature

String path_real(String path)

Parameters

path : path to resolve
return value : the canonical absolute path, or "" if it cannot be resolved

Resolves a path to its canonical absolute form, following symlinks and collapsing . and .. segments. The path must exist. Combine with path_is_within() to validate that user-supplied paths stay inside an allowed root.

Example

file_put_contents("/tmp/doc-real.txt", "x");
print(path_real("/tmp/../tmp/./doc-real.txt"), "\n");
Output
/tmp/doc-real.txt