$path = '/var/www/example.com/public_html/../index.php'; $cleanPath = cleanPath($path); echo $cleanPath; // Output: /var/www/example.com/index.php
$path = '../../private/passwords.txt'; $cleanPath = cleanPath($path); echo $cleanPath; // Output: falseIn this example, the cleanPath function detects that the file path tries to traverse above the root directory and returns false. The cleanPath function is part of the FD (Filesystem Directory) package library, which is a collection of PHP functions related to filesystem operations.