Yeodan Posted March 25, 2009 Share Posted March 25, 2009 Say I have this: index.php <?php include 'something.php'; echo $name; something.php <?php $name = "Yeodan"; ?> Will $name still be defined in index.php where I used it? How can do I remove the variable? Also are the <?php ?> tags needed in the something.php if I already have them in the index.php? Link to comment https://forums.phpfreaks.com/topic/151057-solved-whenhow-do-variables-die/ Share on other sites More sharing options...
Mark Baker Posted March 25, 2009 Share Posted March 25, 2009 Will $name still be defined in index.php where I used it? Yes How can do I remove the variable? unset($name); Also are the <?php ?> tags needed in the something.php if I already have them in the index.php? Yes Link to comment https://forums.phpfreaks.com/topic/151057-solved-whenhow-do-variables-die/#findComment-793556 Share on other sites More sharing options...
Yesideez Posted March 25, 2009 Share Posted March 25, 2009 In short, yes but only after the point where the file was included. If register globals is turned on then yes, it would be carried over from the include file. This is how it used to be set up but caused a LOT of problems (mainly security) so globals are turned off by default. Variables die when a script terminates or when you kill them manually. Here's the "Matrix" question... where do the contents go when they die??? EDIT: Edited first line of my response. Link to comment https://forums.phpfreaks.com/topic/151057-solved-whenhow-do-variables-die/#findComment-793557 Share on other sites More sharing options...
trq Posted March 25, 2009 Share Posted March 25, 2009 To the OP, I'd ignore Yesideez's reply, Mark Baker hit the nail on the head. Link to comment https://forums.phpfreaks.com/topic/151057-solved-whenhow-do-variables-die/#findComment-793559 Share on other sites More sharing options...
Yesideez Posted March 25, 2009 Share Posted March 25, 2009 I would ignore me as well - I didn't read the question properly. Link to comment https://forums.phpfreaks.com/topic/151057-solved-whenhow-do-variables-die/#findComment-793562 Share on other sites More sharing options...
trq Posted March 25, 2009 Share Posted March 25, 2009 I would ignore me as well - I didn't read the question properly. It happens. Link to comment https://forums.phpfreaks.com/topic/151057-solved-whenhow-do-variables-die/#findComment-793566 Share on other sites More sharing options...
Mark Baker Posted March 25, 2009 Share Posted March 25, 2009 Here's the "Matrix" question... where do the contents go when they die???The variable name is normally buried, or cremated and the ashes scattered over the CPU. The variable value goes to the great stack dump in the sky. Link to comment https://forums.phpfreaks.com/topic/151057-solved-whenhow-do-variables-die/#findComment-793568 Share on other sites More sharing options...
Yesideez Posted March 25, 2009 Share Posted March 25, 2009 http://www.joke-archives.com/computers/deletedcharacters.html Link to comment https://forums.phpfreaks.com/topic/151057-solved-whenhow-do-variables-die/#findComment-793569 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.