How can PHP be used to extract parameters from a URL?
To extract parameters from a URL in PHP, you can use the `$_GET` superglobal array. This array contains key-value pairs of parameters passed in the URL query string. To access a specific parameter, you can use the parameter name as the key in the `$_GET` array.
// Example URL: http://example.com/index.php?id=123&name=John
$id = $_GET['id']; // $id will contain '123'
$name = $_GET['name']; // $name will contain 'John'
echo "ID: " . $id . "<br>";
echo "Name: " . $name;
Keywords
Related Questions
- How can PHP be used to automatically populate a table with user information from a registration form, while excluding passwords?
- How can I efficiently handle pagination and retrieving additional data beyond the initial API response in PHP?
- What is the best practice for allowing FTP access to modify files uploaded via PHP?