$file_path = '/var/www/html/uploads/image.jpg'; $folder_dir = ilUtil::getDir($file_path); echo $folder_dir; // Output: /var/www/html/uploads
$dir_path = dirname(__FILE__); $config_file = $dir_path . '/config.ini'; $config_dir = ilUtil::getDir($config_file); echo $config_dir; // Output: /var/www/html/includesIn this example, the dirname function is used to get the directory path of the executing script. Then, the getDir function is used to get the directory path of the config.ini file located in the same directory as the executing script. The output shows the directory path of the includes folder. The ilUtil library is part of the ILIAS package, which is an open-source learning management system written in PHP. It provides various utility functions that can be used to simplify common tasks in ILIAS extension development.