PHP $_SERVER详细用法分析
Argument Result
PHP_SELF Returns the path and filename of the current script
SERVER_PROTOCOL Returns the name and revision of the page-requested protocol
REQUEST_METHOD Returns the request method used to access the page
REQUEST_TIME Returns the timestamp from the beginning of the request
DOCUMENT_ROOT Returns the root directory of the current script
HTTP_REFERER Returns the page address that referred to the current page
HTTP_USER_AGENT Returns the user agent of the header from the current request
REMOTE_ADDR Returns the IP address of the current user
REMOTE_PORT Returns the port of the user's machine that is accessing the page
SCRIPT_FILENAME Returns the absolute filename from the current script
SCRIPT_NAME Returns the path of the current script
<?php教程 if ($_SERVER['REQUEST_METHOD'] == 'GET') { <form action="<?php echo $_SERVER['SCRIPT_NAME'] " method="post"> What is your first name? <input type="text" name="first_name" /> <input type="submit" value="Say Hello" /> </form> <?php } else { echo 'Hello, ' . $_POST['first_name'] . '!'; }
获取用户的IP地址
<?php $address = $_SERVER['REMOTE_ADDR']; $referer = $_SERVER['HTTP_REFERER']; $browser = $_SERVER['HTTP_USER_AGENT']; $file = fopen("log.html", "a"); $time = date("H:i dS F"); fwrite( $file, "<b>Time:</b> $time<br>" ); if( $address != null) { fwrite( $file, "<b>IP Address:</b> $address <br>"); } if( $referer != null) { fwrite( $file, "<b>Referer:</b> $referer<br>"); } fwrite( $file, "<b>Browser:</b> $browser<br/><hr>"); fclose($file);
脚本显示方法
<?php $lastmod = filemtime($_SERVER['SCRIPT_FILENAME']); echo 'file was updated on ' . date('l d F Y, at H:i:s T', $lastmod);
获取服务器时间
<?php $lastmod = filemtime($_SERVER['SCRIPT_FILENAME']); echo 'This file was last updated on ' . date('l d F Y, at H:i:s T', $lastmod) . '.';
本文地址:
转载随意,但请附上文章地址:-)

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

EditPlus 中文破解版
體積小,語法高亮,不支援程式碼提示功能

SublimeText3漢化版
中文版,非常好用

MinGW - Minimalist GNU for Windows
這個專案正在遷移到osdn.net/projects/mingw的過程中,你可以繼續在那裡關注我們。 MinGW:GNU編譯器集合(GCC)的本機Windows移植版本,可自由分發的導入函式庫和用於建置本機Windows應用程式的頭檔;包括對MSVC執行時間的擴展,以支援C99功能。 MinGW的所有軟體都可以在64位元Windows平台上運作。

mPDF
mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),

DVWA
Damn Vulnerable Web App (DVWA) 是一個PHP/MySQL的Web應用程序,非常容易受到攻擊。它的主要目標是成為安全專業人員在合法環境中測試自己的技能和工具的輔助工具,幫助Web開發人員更好地理解保護網路應用程式的過程,並幫助教師/學生在課堂環境中教授/學習Web應用程式安全性。 DVWA的目標是透過簡單直接的介面練習一些最常見的Web漏洞,難度各不相同。請注意,該軟體中