Jump to content

Function Question


shane18

Recommended Posts

Oh i thought you meant a normal variable created outside the function and you want access to it inside the function,

 

Session is just one of the superglobals and can be referenced in the globals array.

 

$GLOBALS['_SESSION']['user_id']

 

would contain the same as

 

$_SESSION['user_id']

 

can be used anywhere, ie in functions etc

Link to comment
https://forums.phpfreaks.com/topic/186480-function-question/#findComment-984732
Share on other sites

If I have a variable.... $_SESSION["USER_ID"];

 

to use that data in a function would i had to include it like this

 

blah($_SESSION["USER_ID"],0,24,53,"bbblllaaahhh");

 

cuz don't functions only have access to whats sent to them or is created in them?

 

$_POST, $_SESSION, $_GET, $_REQUEST, $_SERVER are all 'super globals' already and don't need to be passed through to the  function, You don't have to worry about that.

 

EDIT: Brandon_r, and OP, read this: http://php.net/manual/en/language.variables.predefined.php It's of relevance.

Link to comment
https://forums.phpfreaks.com/topic/186480-function-question/#findComment-984733
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.