How can one determine if PHP is running in CGI mode on a server?

To determine if PHP is running in CGI mode on a server, you can create a PHP script that checks the value of the `SERVER_SOFTWARE` server variable. If the value contains "CGI", then PHP is running in CGI mode. You can use this information to adjust your PHP code accordingly.

<?php
if (strpos($_SERVER['SERVER_SOFTWARE'], 'CGI') !== false) {
    echo 'PHP is running in CGI mode';
} else {
    echo 'PHP is not running in CGI mode';
}
?>