What is the correct way to pass the directory path to functions like filesize and filemtime in PHP?

When passing a directory path to functions like filesize and filemtime in PHP, you need to make sure to include the filename in the path as well. These functions require a complete file path, not just a directory path. You can use the concatenation operator (.) to append the filename to the directory path before passing it to the function.

$directoryPath = '/path/to/directory/';
$filename = 'example.txt';
$filePath = $directoryPath . $filename;

$fileSize = filesize($filePath);
$fileModifiedTime = filemtime($filePath);

echo "File size: $fileSize bytes\n";
echo "Last modified: " . date('Y-m-d H:i:s', $fileModifiedTime) . "\n";