Jump to content

[SOLVED] when/how do variables die


Yeodan

Recommended Posts

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

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??? :P

 

EDIT: Edited first line of my response.

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.