How can PHP be used to protect directory names on a server from being guessed?

Directory names on a server can be protected from being guessed by using an index.php file in each directory to prevent direct access. This file can include code to check if the request is coming from a valid source and redirect the user if not.

```php
<?php
if(!defined('INDEX_CHECK')) {
    header("Location: /");
    exit;
}
// Directory content goes here
?>
```

In each directory that needs protection, create an index.php file with the above code snippet. This will prevent direct access to the directory and its contents unless the request comes from a valid source.