GET URL parameter in PHP

前端 未结 9 983
旧时难觅i
旧时难觅i 2020-11-22 07:32

I\'m trying to pass a URL as a url parameter in php but when I try to get this parameter I get nothing

I\'m using the following url form:

http://loc         


        
9条回答
  •  既然无缘
    2020-11-22 08:03

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

    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:

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

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

提交回复
热议问题