$url = 'https://www.example.com'; if (Director::isLive($url)) { echo 'The URL is live.'; } else { echo 'The URL is not live.'; }
$urls = ['https://www.example.com', 'https://www.google.com', 'https://www.facebook.com']; foreach ($urls as $url) { if (Director::isLive($url)) { echo 'The URL ' . $url . ' is live.' . PHP_EOL; } else { echo 'The URL ' . $url . ' is not live.' . PHP_EOL; } }This code example checks whether multiple URLs are live or not using the Director isLive function. It loops through an array of URLs and prints whether each URL is live or not. It uses the PHP_EOL constant to add a new line after each URL output. The Director isLive function is part of the SilverStripe Framework package library. The SilverStripe Framework is a PHP framework and content management system that provides a range of modules and tools for building web applications.