To answer the headline : the best way is to disable display_errors .
What exactly are you using isset() ?
Note: For those who complain that this "disables" all errors - from the PHP manual :
This is a support function for your development and should never be used on production systems (such as systems connected to the Internet).
After editing:. You can either make sure that the variables you are going to use have some value (just blindly repeating get / post var is not best practice) - or you can use an object to store the variables you want to output (as properties) and use __get() to return an empty string (or false) when the property has not been set.
This will leave you with something like:
echo $view->something; if($view->something){
I believe this will be similar to what many template / presentation libraries do.
Update . He noted this old (ish) answer and thought that something could be added to it. For this use case (where values may or may not be in an array), array_merge() can be used:
$default = array('user' => false); $params = array_merge($default, $_GET); if($params['user']){ //safe to use, will have default value if not in $_GET }
Tim lytle
source share