How to obtain parameter values from the current URL in php?

In PHP, you can use the $_GET superglobal variable to retrieve parameter values from a URL. For example, if the URL is http://example.com/index.php?id=123&name=John, you can obtain the values of the id and name parameters using the following code:

$id = $_GET['id'];
$name = $_GET['name'];

echo $id; // 输出 123
echo $name; // 输出 John

Please note that $_GET can only retrieve parameter values passed through the GET method. If parameters are passed through the POST method, you need to use the $_POST superglobal variable to retrieve the parameter values.

Leave a Reply 0

Your email address will not be published. Required fields are marked *


广告
Closing in 10 seconds
bannerAds