Re: re-using variables



Mitesh wrote:
$res = mysql_query($req);
.............
$res = mysql_query($req);
In other words since PHP uses garbage collection re-using the same
variable can cause problems. Is this true?

Using the same variable twice is fine. Don't bother too much about the garbage collector. Since it removes variables when you don't use them anymore, it never gets in the way.

You probably have another problem which causes things to fail sometimes.

Sjoerd
.



Relevant Pages

  • Re: Object suicude
    ... process regularly chew up half a gig of memory. ... > In PHP is this its equivalent of destroying an object, say, if you ... > there is some means of garbage collection. ...
    (comp.lang.php)
  • Re: Object suicude
    ... > In PHP is this its equivalent of destroying an object, say, if you ... > there is some means of garbage collection. ... anything else it will not free up memory used by that object. ...
    (comp.lang.php)
  • Re: Object suicude
    ... >> In PHP is this its equivalent of destroying an object, say, if you ... >> there is some means of garbage collection. ... > anything else it will not free up memory used by that object. ...
    (comp.lang.php)
  • Re: can I "dispose" of an array?
    ... Or does PHP ... have some sort of garbage collection? ... Or do things just hang out until ...
    (comp.lang.php)
  • re-using variables
    ... $res = mysql_query; ... What I have discovered is re-using the $req variable is fine. ... In other words since PHP uses garbage collection re-using the same ...
    (comp.lang.php)