Get parameter from URL Using PHP

The simplest way is:

echo $_GET['link'];

$_GET is not a function or language construct—it’s just a variable (an array).

Since the variable might not exist, you could (and should) ensure your code does not trigger notices with:

if (isset($_GET['link'])) {
    echo $_GET['link'];
} else {
    // Fallback behaviour goes here

Alternatively, if you want to skip manual index checks and maybe add further validations you can use the filter extension:

echo filter_input(INPUT_GET, 'link', FILTER_SANITIZE_URL);

Last but not least, you can use the null coalescing operator (available since PHP/7.0) to handle missing parameters:

echo $_GET['link'] ?? 'Fallback value';

Also you can try:

echo $_REQUEST['link'];

Leave a Comment

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

Scroll to Top