How to make quick judgement and assignment without isset()?
I am tired of using code like: $blog = isset($_GET['blog']) ? $_GET['blog'] : 'default'; but I can't use: $blog = $_GET['blog'] || 'default'; Is there any way to do this without using isset() ? You have to wait for the next version of PHP to get the coalesce operator // Uses $_GET['user'] if it exists -- or 'nobody' if it doesn't $username = $_GET['user'] ?? 'nobody'; // Loads some data from the model and falls back on a default value $model = Model::get($id) ?? $default_model; Write a helper function. function arrayValue($array, $key, $default = null) { return isset($array[$key]) ? $array[