GET URL parameter in PHP GET URL parameter in PHP php php

GET URL parameter in PHP


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

<?phpecho $_GET['link'];

In particular, it's a superglobal: a built-in variable that's populated by PHP and is available in all scopes (you can use it from inside a function without the global keyword).

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

<?phpif (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:

<?phpecho 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';


Please post your code,

<?php    echo $_GET['link'];?>

or

<?php    echo $_REQUEST['link'];?>

do work...


Use this:

$parameter = $_SERVER['QUERY_STRING'];echo $parameter;

Or just use:

$parameter = $_GET['link'];echo $parameter ;