php - non-initialized referenced variable doesn't throw notice -
i have function takes variable reference:
function get_articles($limit = 10, &$more = false){ $results = get_results_from_db($limit); $more = ($results->found > $limit) ? $results->found : false; return $results->data; } which use like:
$articles = get_articles(10, $more_results); foreach($articles $article){ // stuff } if($more_results) // have more 10 results but don't notice telling me $more_results above undefined... normal?
yes, because $more_results defined @ least false value (after calling function).
inside function variable not defined, since doesn't read content of variable, notice not generated.
Comments
Post a Comment