I use method $_GET to create dynamics URLs:
$page = $_GET['id'];
URL: mysite.com/index.php?id=1
But, if someone insert a maleficent URL?
URL: mysite.com/index.php&id=http://www.infectedsite.com/viruses.txt?
How to treat it?
I use method $_GET to create dynamics URLs:
$page = $_GET['id'];
URL: mysite.com/index.php?id=1
But, if someone insert a maleficent URL?
URL: mysite.com/index.php&id=http://www.infectedsite.com/viruses.txt?
How to treat it?
It is easy to handle. You handle exactly how the query parameter is used, so make sure you take proper precautions when you use the parameter.
If you are dealing with database queries, make sure you properly escape your get parameter. This differs depending what you are using, but some useful pages to read are: http://php.net/manual/en/function.mysql-real-escape-string.php (deprecated, but will give you a good understanding of escaping strings), and prepared statements in the PDO library http://php.net/manual/en/pdo.prepared-statements.php
The other thing to be aware of is Cross Site Scripting (XSS). A good source to read on that is https://www.owasp.org/index.php/Cross-site_Scripting_(XSS). Simply by thinking about how you may be attacked like this will allow you to protect against it in your code. The webpage linked gives good advice in this respect too.
Also mentioned by Brad in the comments, PHP provides a range of filtering functions. These can be used to both sanitize and validate your data. Examples of this are at http://php.net/manual/en/book.filter.php.
Other than that, mainly use your common sense when using request parameters. If it feels wrong, or insecure, it probably is.