Php gets the value of $ _ SERVER [REQUEST_URI. Among the many predefined SERVER variables in PHP, $ _ SERVER [REQUEST_URI] is frequently used, but this variable is only supported by apache. therefore, among the many predefined SERVER variables in PHP, $ _ SERVER ["REQUEST_URI"] is often used, but this variable is only supported by apache. therefore, we need a more general method to obtain the value of REQUEST_URI.
The code is as follows: |
|
Function request_uri () { If (isset ($ _ SERVER ['request _ URI ']) { $ Uri = $ _ SERVER ['request _ URI ']; } Else { If (isset ($ _ SERVER ['argv']) { $ Uri = $ _ SERVER ['php _ SELF '].'? '. $ _ SERVER ['argv'] [0]; } Else { $ Uri = $ _ SERVER ['php _ SELF '].'? '. $ _ SERVER ['query _ string']; } } Return $ uri; } ?> |
Among the many predefined SERVER variables in PHP, $ _ SERVER [REQUEST_URI] is often used, but this variable is only supported by apache. Therefore, we need a more general method...