라이브러리
[PHP] Yaf_Request_Abstract::getServer - SERVER 변수 검색
Yaf_Request_Abstract::getServer는 PHP의 Yaf 프레임워크에서 사용되는 메소드입니다. 이 메소드는 HTTP 요청의 서버 변수를 가져올 수 있도록 해줍니다.
Yaf_Request_Abstract::getServer의 사용 방법
Yaf_Request_Abstract::getServer 메소드는 다음과 같이 사용할 수 있습니다.
#hostingforum.kr
php
$request = Yaf_Request_Abstract::getInstance();
$server = $request->getServer();
Yaf_Request_Abstract::getServer의 매개변수
Yaf_Request_Abstract::getServer 메소드는 하나의 매개변수를 받을 수 있습니다. 이 매개변수는 서버 변수의 이름입니다.
#hostingforum.kr
php
$request = Yaf_Request_Abstract::getInstance();
$server = $request->getServer('HTTP_HOST');
Yaf_Request_Abstract::getServer의 예제
Yaf_Request_Abstract::getServer 메소드는 다음과 같이 사용할 수 있습니다.
#hostingforum.kr
php
// Yaf_Request_Abstract::getInstance()를 사용하여 요청 객체를 가져옵니다.
$request = Yaf_Request_Abstract::getInstance();
// HTTP_HOST 서버 변수를 가져옵니다.
$host = $request->getServer('HTTP_HOST');
// HTTP_USER_AGENT 서버 변수를 가져옵니다.
$agent = $request->getServer('HTTP_USER_AGENT');
// HTTP_REFERER 서버 변수를 가져옵니다.
$referer = $request->getServer('HTTP_REFERER');
// 결과를 출력합니다.
echo "HTTP_HOST: $host
";
echo "HTTP_USER_AGENT: $agent
";
echo "HTTP_REFERER: $referer
";
Yaf_Request_Abstract::getServer의 결과
위 예제의 결과는 다음과 같습니다.
#hostingforum.kr
HTTP_HOST: localhost
HTTP_USER_AGENT: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.3
HTTP_REFERER: http://localhost/
위 예제는 Yaf_Request_Abstract::getServer 메소드를 사용하여 HTTP_HOST, HTTP_USER_AGENT, HTTP_REFERER 서버 변수를 가져오고, 결과를 출력합니다.
-
- 나우호스팅 @pcs8404
-
호스팅포럼 화이팅!
댓글목록
등록된 댓글이 없습니다.