This article introduces an example of the global variable $_SERVER in PHP. Friends in need can refer to it.
Example 1, loop to list the values in the global variable $_SERVER <?php foreach ($_SERVER as $var => $value) { echo "$var => $value <br />"; } ?> Copy after login Example 2, get the last update time of the file <?php $lastmod = filemtime($_SERVER['SCRIPT_FILENAME']); echo '此文件的最后更新时间 ' . date('l d F Y, \a\t H:i:s T', $lastmod) . '.'; ?> Copy after login Example 3, get the update date and time of the file <?php $lastmod = filemtime($_SERVER['SCRIPT_FILENAME']); echo '文件更新时间:' . date('l d F Y, \a\t H:i:s T', $lastmod); ?> Copy after login Example 4, site environment variable information <?php $version = $_SERVER['SITE_VERSION']; if ('members' == $version) { if (!authenticate_user($_POST['username'], $_POST['password'])) { header('Location: http://bbs.it-home.org/'); exit; } } include_once "${version}_header"; //加载版本头信息 Copy after login |