PHP: a variable inside a function uses it outside the function?

Im includes almost every page in page_protect () ;, I made a variable for userid, $ userid, with the user id. Therefore, it will be much easier for me to get an identifier than to call SESSION_id every time on every page.

How can I use a variable inside this function outside the function?

+4
source share
1 answer
function page_protect() { global $id; $id = 1234; } page_protect(); echo $id; 
+13
source

All Articles