What are some potential issues when using PHP to display directories and files in a web application?

One potential issue when using PHP to display directories and files in a web application is that it can expose sensitive information such as file paths or file names to users. To solve this issue, you can use the `basename()` function in PHP to only display the file names without the full path.

$directory = "path/to/directory";

$files = scandir($directory);

foreach($files as $file){
    if($file != '.' && $file != '..'){
        echo basename($file) . "<br>";
    }
}