To obtain parameters from the URL in PHP, you can use the $_GET super global variable: Make sure the request method is GET. Use the $_GET array to access parameters: keys are parameter names and values are parameter values.
How to get parameters from URL in PHP
In order to get parameters from URL in PHP, you You can use the$_GET
superglobal variable.
Steps:
GET
. You can use$_SERVER['REQUEST_METHOD']
to get the request method.GET
, you can use the$_GET
array to access the parameters in the query string.$_GET
The array is an associative array where the keys are parameter names and the values are parameter values.Example:
The following example demonstrates how to retrieve a file from the URLhttps://example.com/index.php?name=John&age=30
Get parameters in:
Output:
姓名:John 年龄:30
The above is the detailed content of How to get parameters from URL in php. For more information, please follow other related articles on the PHP Chinese website!