if(isset($request['param1'])) ...
equivalent to:
if($request->contains('param1')) ...
To get the value of 'param1', use,
$value=$request['param1'];
equivalent to:
$value=$request->itemAt('param1');
To traverse the user post data, use
foreach($request as $name=>$value) ...
Note, POST and GET variables are merged together in THttpRequest.
If a variable name appears in both POST and GET data, then POST data
takes precedence.
To construct a URL that can be recognized by Prado, use {@link constructUrl()}.
The format of the recognizable URLs is determined according to
{@link setUrlManager UrlManager}. By default, the following two formats
are recognized:
index.php?ServiceID=ServiceParameter&Name1=Value1&Name2=Value2
index.php/ServiceID,ServiceParameter/Name1,Value1/Name2,Value2
The first format is called 'Get' while the second 'Path', which is specified
via {@link setUrlFormat UrlFormat}. For advanced users who want to use
their own URL formats, they can write customized URL management modules
and install the managers as application modules and set {@link setUrlManager UrlManager}.
The ServiceID in the above URLs is as defined in the application configuration
(e.g. the default page service's service ID is 'page').
As a consequence, your GET variable names should not conflict with the service
IDs that your application supports.
THttpRequest also provides the cookies sent by the user, user information such
as his browser capabilities, accepted languages, etc.
By default, THttpRequest is registered with {@link TApplication} as the
request module. It can be accessed via {@link TApplication::getRequest()}.
Показать файл
Открыть проект
Примеры использования класса
Метод | Описание | |
---|---|---|
add ( $key, $value ) | Adds an item into the request. | |
clear ( ) | Removes all items in the request. | |
constructUrl ( $serviceID, $serviceParam, $getItems = null, $encodeAmpersand = true, $encodeGetItems = true ) : string | Constructs a URL that can be recognized by PRADO. | |
contains ( $key ) : boolean | ||
count ( ) : integer | Returns the number of items in the request. | |
getAbsoluteApplicationUrl ( $forceSecureConnection = null ) : string | ||
getAcceptTypes ( ) : string | ||
getApplicationFilePath ( ) : string | ||
getApplicationUrl ( ) : string | ||
getBaseUrl ( $forceSecureConnection = null ) : string | ||
getBrowser ( ) : array | ||
getCgiFix ( ) : integer | ||
getContentType ( boolean $mimetypeOnly = true ) : string | ||
getCookies ( ) : |
||
getCount ( ) : integer | ||
getEnableCache ( ) : boolean | ||
getEnableCookieValidation ( ) : boolean | ||
getEnvironmentVariables ( ) : array | ||
getHeaders ( $case = null ) : array | ||
getHttpProtocolVersion ( ) : string | ||
getID ( ) : string | ||
getIsSecureConnection ( ) : boolean | ||
getIterator ( ) : Iterator | Returns an iterator for traversing the items in the list. | |
getKeys ( ) : array | ||
getPathInfo ( ) : string | ||
getQueryString ( ) : string | ||
getRequestResolved ( ) : boolean | ||
getRequestType ( ) : string | ||
getRequestUri ( ) : string | ||
getServerName ( ) : string | ||
getServerPort ( ) : integer | ||
getServerVariables ( ) : array | ||
getServiceID ( ) : string | ||
getServiceParameter ( ) : string | ||
getUploadedFiles ( ) : array | ||
getUrl ( ) : |
||
getUrlFormat ( ) : |
||
getUrlManager ( ) : string | ||
getUrlManagerModule ( ) : |
||
getUrlParamSeparator ( ) : string | ||
getUrlReferrer ( ) : string | ||
getUserAgent ( ) : string | ||
getUserHost ( ) : string | ||
getUserHostAddress ( ) : string | ||
getUserLanguages ( ) : array | Returns a list of user preferred languages. | |
init ( $config ) | Initializes the module. | |
itemAt ( $key ) : mixed | Returns the item with the specified key. | |
offsetExists ( $offset ) : boolean | Returns whether there is an element at the specified offset. | |
offsetGet ( $offset ) : mixed | Returns the element at the specified offset. | |
offsetSet ( $offset, $item ) | Sets the element at the specified offset. | |
offsetUnset ( $offset ) | Unsets the element at the specified offset. | |
remove ( $key ) : mixed | Removes an item from the request by its key. | |
resolveRequest ( $serviceIDs ) : string | Resolves the requested service. | |
setCgiFix ( $value ) | Enable this, if you're using PHP via CGI with php.ini setting "cgi.fix_pathinfo=1" and have trouble with friendly URL feature. Enable this only if you really know what you are doing! | |
setEnableCache ( $value ) | Set true to cache the UrlManager instance. Consider to enable this cache when the application defines a lot of TUrlMappingPatterns | |
setEnableCookieValidation ( $value ) | ||
setID ( $value ) | ||
setServiceID ( $value ) | Sets the requested service ID. | |
setServiceParameter ( $value ) | Sets the requested service parameter. | |
setUrlFormat ( $value ) | Sets the format of URLs constructed and interpretted by the request module. | |
setUrlManager ( $value ) | Sets the URL manager module. | |
setUrlParamSeparator ( $value ) | ||
stripSlashes ( &$data ) : mixed | Strips slashes from input data. | |
toArray ( ) : array |
Метод | Описание | |
---|---|---|
cacheUrlManager ( $manager ) : boolean | Saves the current UrlManager instance to cache. | |
getCacheKey ( ) | ||
loadCachedUrlManager ( ) : |
Loads UrlManager instance from cache. | |
parseUrl ( ) : array | Parses the request URL and returns an array of input parameters (excluding GET variables). |
public add ( $key, $value ) |
protected cacheUrlManager ( $manager ) : boolean | ||
Результат | boolean | true if UrlManager instance was cached, false otherwise. |
public constructUrl ( $serviceID, $serviceParam, $getItems = null, $encodeAmpersand = true, $encodeGetItems = true ) : string | ||
Результат | string | URL |
public getAbsoluteApplicationUrl ( $forceSecureConnection = null ) : string | ||
Результат | string | entry script URL (w/ host part) |
public getAcceptTypes ( ) : string | ||
Результат | string | user browser accept types |
public getApplicationFilePath ( ) : string | ||
Результат | string | application entry script file path (processed w/ realpath()) |
public getApplicationUrl ( ) : string | ||
Результат | string | entry script URL (w/o host part) |
public getBaseUrl ( $forceSecureConnection = null ) : string | ||
Результат | string | schema and hostname of the requested URL |
public getBrowser ( ) : array | ||
Результат | array | user browser capabilities |
public getContentType ( boolean $mimetypeOnly = true ) : string | ||
$mimetypeOnly | boolean | whether to return only the mimetype (default: true) |
Результат | string | content type (e.g. 'application/json' or 'text/html; encoding=gzip') or null if not specified |
public getCookies ( ) : |
||
Результат | list of cookies to be sent |
public getEnableCache ( ) : boolean | ||
Результат | boolean | true if urlmanager instance should be cached, false otherwise. |
public getEnableCookieValidation ( ) : boolean | ||
Результат | boolean | whether cookies should be validated. Defaults to false. |
public getEnvironmentVariables ( ) : array | ||
Результат | array | list of environment variables. |
public getHttpProtocolVersion ( ) : string | ||
Результат | string | the requested http procolol. Blank string if not defined. |
public getIsSecureConnection ( ) : boolean | ||
Результат | boolean | if the request is sent via secure channel (https) |
public getIterator ( ) : Iterator | ||
Результат | Iterator | an iterator for traversing the items in the list. |
public getPathInfo ( ) : string | ||
Результат | string | part of the request URL after script name and before question mark. |
public getQueryString ( ) : string | ||
Результат | string | part of that request URL after the question mark |
public getRequestResolved ( ) : boolean | ||
Результат | boolean | true if request is already resolved, false otherwise. |
public getRequestType ( ) : string | ||
Результат | string | request type, can be GET, POST, HEAD, or PUT |
public getRequestUri ( ) : string | ||
Результат | string | part of that request URL after the host info (including pathinfo and query string) |
public getServerPort ( ) : integer | ||
Результат | integer | server port number |
public getServerVariables ( ) : array | ||
Результат | array | list of server variables. |
public getServiceID ( ) : string | ||
Результат | string | requested service ID |
public getServiceParameter ( ) : string | ||
Результат | string | requested service parameter |
public getUploadedFiles ( ) : array | ||
Результат | array | list of uploaded files. |
public getUrlFormat ( ) : |
||
Результат | the format of URLs. Defaults to THttpRequestUrlFormat::Get. |
public getUrlManager ( ) : string | ||
Результат | string | the ID of the URL manager module |
public getUrlManagerModule ( ) : |
||
Результат | the URL manager module |
public getUrlParamSeparator ( ) : string | ||
Результат | string | separator used to separate GET variable name and value when URL format is Path. Defaults to comma ','. |
public getUrlReferrer ( ) : string | ||
Результат | string | URL referrer, null if not present |
public getUserHost ( ) : string | ||
Результат | string | user host name, null if cannot be determined |
public getUserHostAddress ( ) : string | ||
Результат | string | user IP address |
public getUserLanguages ( ) : array | ||
Результат | array | list of user preferred languages. |
public init ( $config ) |
protected loadCachedUrlManager ( ) : |
||
Результат | intance if load was successful, null otherwise. |
public offsetExists ( $offset ) : boolean | ||
Результат | boolean |
public offsetSet ( $offset, $item ) |
public offsetUnset ( $offset ) |
public resolveRequest ( $serviceIDs ) : string | ||
Результат | string | the currently requested service ID, null if no service ID is found |
public setCgiFix ( $value ) |
public setEnableCache ( $value ) |
public setServiceParameter ( $value ) |
public setUrlFormat ( $value ) |
public setUrlManager ( $value ) |
public stripSlashes ( &$data ) : mixed | ||
Результат | mixed | processed data |