require_once 'Director/Path.php'; use \Aloha\Director\Path; // Base path $base_path = '/path/to/base'; // Absolute path to file $file_path = '/path/to/base/folder/file.php'; // Get relative file path $relative_path = Path::makeRelative($file_path, $base_path); // Output: folder/file.php echo $relative_path;
require_once 'Director/Path.php'; use \Aloha\Director\Path; // Base path $base_path = '/path/to/base'; // Absolute path to images folder $image_path = '/path/to/base/images'; // Get relative image path $relative_path = Path::makeRelative($image_path, $base_path); // Output: images echo $relative_path;In this example, the function is used to determine the relative path of an images folder located in the base directory. The $base_path variable is set to the base directory, and the $image_path variable is set to the absolute path of the images folder. The makeRelative function is then used to determine the relative path of the images folder, which is returned as "images". The makeRelative function is part of the Director package library, which is a PHP library for working with file paths and URLs. The Director library provides a range of functions for manipulating file paths, including joining paths, normalizing paths, and converting file paths to URLs.