PHP - is global using to get a variable for example out of the function
localscope and aslo out of the page itself without using require or...
in this example i confront this problem when i was listen to a tutorial
and the instructor didn't refer to the global he wrote in the function and
the inquiry was about the global he wrote inside the function using it to
call a $connection variable but he didn't include or require the page that
has the variable in it. so my question is can global cross all the pages
without include or require it ?
function get_pages_for_subject($subject_id){
global $connection;
$query = "SELECT * FROM pages
WHERE subject_id = {$subject_id}
ORDER BY position ASC";
$page_set = mysql_query($query);
confirm_query($page_set);
return $page_set;
}
No comments:
Post a Comment