Get parameter from URL Using PHP

0

The simplest way is:

<?php
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:

<?php
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:

<?php
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:

<?php
echo $_REQUEST['link'];
We will be happy to hear your thoughts

Leave a reply

CodeROG
Logo
Reset Password
Compare items
  • Total (0)
Compare
0
Shopping cart