I keep getting this as a warning I want to avoid getting this warning when it is undefined without turning warnings off
here is the context
$url_items = array("foo");
$article_id = db_escape($url_items[1]);
$article = get_article($article_id);
function get_article($article_id = NULL) {.....}
I’m thinking that the easiest way to solve it is like this:
This should works because you give
$article_ida default value in the function. However, you could just as easily change the middle ternary part to null if you don’t want to execute at all if there is no$article_id.Edit: If you have an article_id 0, you may want to change
emptyto!issetEdit 2: Modified to avoid the undefined offset warning.