PHP 클래스 Contao\Environment

The class returns the environment variables (which are stored in the PHP $_SERVER array) independent of the operating system. Usage: echo Environment::get('scriptName'); echo Environment::get('requestUri');
파일 보기 프로젝트 열기: contao/core-bundle 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$arrCache array Cache
$objInstance Environment Object instance (Singleton)
$strSapi string The SAPI name

공개 메소드들

메소드 설명
__clone ( ) Prevent cloning of the object (Singleton)
__get ( string $strKey ) : string Return an environment variable
__set ( string $strKey, mixed $varValue ) Set an environment variable
get ( string $strKey ) : mixed Return an environment variable
getInstance ( ) : Environment Return the object instance (Singleton)
reset ( ) Reset the internal cache
set ( string $strKey, mixed $varValue ) Set an environment variable

보호된 메소드들

메소드 설명
__construct ( ) Prevent direct instantiation (Singleton)
agent ( ) : object Return the operating system and the browser name and version
base ( ) : string Return the URL and path that can be used in a tag
documentRoot ( ) : string Return the document root (e.g. /home/www/user/)
encodeRequestString ( string $strRequest ) : string Encode a request string preserving certain reserved characters
host ( ) : string Return the host name
httpAcceptEncoding ( ) : array Return accepted encoding types as array
httpAcceptLanguage ( ) : array Return the first eight accepted languages as array
httpHost ( ) : string Return the HTTP Host
httpUserAgent ( ) : string Return the user agent as string
httpXForwardedHost ( ) : string Return the HTTP X-Forwarded-Host
indexFreeRequest ( ) : string Return the request string without the index.php fragment
ip ( ) : string Return the real REMOTE_ADDR even if a proxy server is used
isAjaxRequest ( ) : boolean Return true on Ajax requests
path ( ) : string Return the relative path to the base directory (e.g. /path)
phpSelf ( ) : string Alias for scriptName()
queryString ( ) : string Return the query string (e.g. id=2)
relativeRequest ( ) : string Return the request string without the script name (e.g. en/news.html)
request ( ) : string Return the relativ path to the script and include the request (e.g. index.php?id=2)
requestUri ( ) : string Return the request URI [path]?[query] (e.g. /contao/index.php?id=2)
script ( ) : string Return the relativ path to the script (e.g. index.php)
scriptFilename ( ) : string Return the absolute path to the script (e.g. /home/www/html/website/index.php)
scriptName ( ) : string Return the relative path to the script (e.g. /website/index.php)
server ( ) : string Return the SERVER_ADDR
ssl ( ) : boolean Return true if the current page was requested via an SSL connection
uri ( ) : string Return the current URL with path or query string
url ( ) : string Return the current URL without path or query string

메소드 상세

__clone() 최종 공개 메소드

Prevent cloning of the object (Singleton)
사용 중단: Deprecated since Contao 4.0, to be removed in Contao 5.0. The Environment class is now static.
final public __clone ( )

__construct() 보호된 메소드

Prevent direct instantiation (Singleton)
사용 중단: Deprecated since Contao 4.0, to be removed in Contao 5.0. The Environment class is now static.
protected __construct ( )

__get() 공개 메소드

Return an environment variable
사용 중단: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Environment::get() instead.
public __get ( string $strKey ) : string
$strKey string The variable name
리턴 string The variable value

__set() 공개 메소드

Set an environment variable
사용 중단: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Environment::set() instead.
public __set ( string $strKey, mixed $varValue )
$strKey string The variable name
$varValue mixed The variable value

agent() 보호된 정적인 메소드

Return the operating system and the browser name and version
protected static agent ( ) : object
리턴 object The agent information

base() 보호된 정적인 메소드

Return the URL and path that can be used in a tag
protected static base ( ) : string
리턴 string The base URL

documentRoot() 보호된 정적인 메소드

Calculated as SCRIPT_FILENAME minus SCRIPT_NAME as some CGI versions and mod-rewrite rules might return an incorrect DOCUMENT_ROOT.
protected static documentRoot ( ) : string
리턴 string The document root

encodeRequestString() 보호된 정적인 메소드

Encode a request string preserving certain reserved characters
protected static encodeRequestString ( string $strRequest ) : string
$strRequest string The request string
리턴 string The encoded request string

get() 공개 정적인 메소드

Return an environment variable
public static get ( string $strKey ) : mixed
$strKey string The variable name
리턴 mixed The variable value

getInstance() 공개 정적인 메소드

Return the object instance (Singleton)
사용 중단: Deprecated since Contao 4.0, to be removed in Contao 5.0. The Environment class is now static.
public static getInstance ( ) : Environment
리턴 Environment The object instance

host() 보호된 정적인 메소드

Return the host name
protected static host ( ) : string
리턴 string The host name

httpAcceptEncoding() 보호된 정적인 메소드

Return accepted encoding types as array
protected static httpAcceptEncoding ( ) : array
리턴 array The encoding types array

httpAcceptLanguage() 보호된 정적인 메소드

Return the first eight accepted languages as array
protected static httpAcceptLanguage ( ) : array
리턴 array The languages array

httpHost() 보호된 정적인 메소드

Return the HTTP Host
protected static httpHost ( ) : string
리턴 string The host name

httpUserAgent() 보호된 정적인 메소드

Return the user agent as string
protected static httpUserAgent ( ) : string
리턴 string The user agent string

httpXForwardedHost() 보호된 정적인 메소드

Return the HTTP X-Forwarded-Host
protected static httpXForwardedHost ( ) : string
리턴 string The name of the X-Forwarded-Host

indexFreeRequest() 보호된 정적인 메소드

Return the request string without the index.php fragment
protected static indexFreeRequest ( ) : string
리턴 string The request string without the index.php fragment

ip() 보호된 정적인 메소드

Return the real REMOTE_ADDR even if a proxy server is used
protected static ip ( ) : string
리턴 string The IP address of the client

isAjaxRequest() 보호된 정적인 메소드

Return true on Ajax requests
protected static isAjaxRequest ( ) : boolean
리턴 boolean True if it is an Ajax request

path() 보호된 정적인 메소드

Return the relative path to the base directory (e.g. /path)
protected static path ( ) : string
리턴 string The relative path to the installation

phpSelf() 보호된 정적인 메소드

Alias for scriptName()
protected static phpSelf ( ) : string
리턴 string The script name

queryString() 보호된 정적인 메소드

Return the query string (e.g. id=2)
protected static queryString ( ) : string
리턴 string The query string

relativeRequest() 보호된 정적인 메소드

Return the request string without the script name (e.g. en/news.html)
protected static relativeRequest ( ) : string
리턴 string The base URL

request() 보호된 정적인 메소드

Return the relativ path to the script and include the request (e.g. index.php?id=2)
protected static request ( ) : string
리턴 string The relative path to the script including the request string

requestUri() 보호된 정적인 메소드

Return the request URI [path]?[query] (e.g. /contao/index.php?id=2)
protected static requestUri ( ) : string
리턴 string The request URI

reset() 공개 정적인 메소드

Reset the internal cache
public static reset ( )

script() 보호된 정적인 메소드

Return the relativ path to the script (e.g. index.php)
protected static script ( ) : string
리턴 string The relative path to the script

scriptFilename() 보호된 정적인 메소드

Return the absolute path to the script (e.g. /home/www/html/website/index.php)
protected static scriptFilename ( ) : string
리턴 string The absolute path to the script

scriptName() 보호된 정적인 메소드

Return the relative path to the script (e.g. /website/index.php)
protected static scriptName ( ) : string
리턴 string The relative path to the script

server() 보호된 정적인 메소드

Return the SERVER_ADDR
protected static server ( ) : string
리턴 string The IP address of the server

set() 공개 정적인 메소드

Set an environment variable
public static set ( string $strKey, mixed $varValue )
$strKey string The variable name
$varValue mixed The variable value

ssl() 보호된 정적인 메소드

Return true if the current page was requested via an SSL connection
protected static ssl ( ) : boolean
리턴 boolean True if SSL is enabled

uri() 보호된 정적인 메소드

Return the current URL with path or query string
protected static uri ( ) : string
리턴 string The URL

url() 보호된 정적인 메소드

Return the current URL without path or query string
protected static url ( ) : string
리턴 string The URL

프로퍼티 상세

$arrCache 보호되어 있는 정적으로 프로퍼티

Cache
protected static array $arrCache
리턴 array

$objInstance 보호되어 있는 정적으로 프로퍼티

Object instance (Singleton)
protected static Environment,contao $objInstance
리턴 Environment

$strSapi 보호되어 있는 정적으로 프로퍼티

The SAPI name
protected static string $strSapi
리턴 string