Website URL:

http://www.example.com/?id=2

Code:

$id = intval($_GET['id']);
Answer from Steven on Stack Overflow
🌐
PHP
php.net › manual › en › function.parse-url.php
PHP: parse_url - Manual
Specify one of PHP_URL_SCHEME, PHP_URL_HOST, PHP_URL_PORT, PHP_URL_USER, PHP_URL_PASS, PHP_URL_PATH, PHP_URL_QUERY or PHP_URL_FRAGMENT to retrieve just a specific URL component as a string (except when PHP_URL_PORT is given, in which case the return value will be an int).
🌐
W3Schools
w3schools.com › php › php_superglobals_get.asp
PHP $_GET Superglobal
HTML link with URL query parameters: ... subject=PHP · web=W3schools.com · In the PHP file we can use the $_GET superglobal to collect the value of the query string....
🌐
Nabilhassen
nabilhassen.com › how-to-read-and-get-url-parameters-in-php
How to Read and Get URL Parameters in PHP - Nabil Hassen
September 24, 2025 - They allow passing small amounts of data in the URL itself. The simplest and most common way to access URL parameters in PHP is via the superglobal $_GET. This is an associative array that PHP fills from the query string of the current request.
🌐
GeeksforGeeks
geeksforgeeks.org › php › how-to-get-parameters-from-a-url-string-in-php
How to get parameters from a URL string in PHP? - GeeksforGeeks
July 11, 2025 - The parameters from a URL string can be retrieved in PHP using parse_url() and parse_str() functions.
🌐
W3Docs
w3docs.com › php
How to Get Parameters from a URL String with PHP | W3Docs
... <‌?php // Initialize URL to the variable $url = 'http://w3docs.com?name=John'; // Use parse_url() function to parse the URL // and return an associative array which // contains its various components $url_components = parse_url($url); ...
🌐
Delft Stack
delftstack.com › home › howto › php › how to get parameters from a url string in php
How to Get Parameters From a URL String in PHP | Delft Stack
February 2, 2024 - <?php $url = "https://testurl.... $results); print_r($results); ?> ... In PHP, we can also use the $_GET variable to get parameters from a URL string....
Find elsewhere
🌐
TutorialsPoint
tutorialspoint.com › how-to-get-parameters-from-a-url-string-in-php
How to get parameters from a URL string in PHP?
December 27, 2019 - In PHP, you can extract parameters from a URL string using the parse_url() function combined with parse_str().
🌐
YouTube
youtube.com › watch
PHP Tutorial - Retrieving values from a URL's query string - YouTube
LinkedIn Learning is the next generation of Lynda.com. Grow your skills by exploring more PHP courses today: https://www.linkedin.com/learning/topics/php?trk
Published: April 18, 2014
🌐
Strangebuzz
strangebuzz.com › home › snippets › extracting the get parameters of an url with php
Extracting the GET parameters of an URL with PHP | Strangebuzz
<?php declare(strict_types=1); namespace App\Controller\Snippet; /** * I am using a PHP trait to isolate each snippet in a file. * This code should be called from a Symfony controller extending AbstractController (as of Symfony 4.2) * or Symfony\Bundle\FrameworkBundle\Controller\Controller (Symfony <= 4.1). * Services are injected in the main controller constructor. */ trait Snippet209Trait { public function snippet209(): void { $url = 'https://www.strangebuzz.com/fr/recherche?q=api+assert&first=value&arr[]=foo+bar&arr[]=baz'; $query = parse_url($url, PHP_URL_QUERY); parse_str($query, $queryString); $q = isset($queryString['q']) && \is_string($queryString['q']) ?
🌐
Plus2Net
plus2net.com › php_tutorial › variables2.php
Passing variables between pages using URL GET or POST method
February 5, 2000 - Any scripting language like ASP, JSP, PHP or Perl running at receiving end can process and collect the value from the query string or from the URL. Easy to save the URL or bookmark it for frequent use. Copy the URL and send it to a friend to refer. Here one main concern is the data gets exposed ...
🌐
Stack Overflow
stackoverflow.com › questions › 33794046 › php-get-value-from-url
PHP - Get value from URL - Stack Overflow
Can I get the 'username' value and respond to that with the index.php? I've looked around and can't seem to find an answer, without using arguments inside the URL.