C vs PHP

From: Date: Sat, 24 Feb 2001 18:41:24 +0000
Subject: C vs PHP
Groups: php.general 
Request: Send a blank email to php-general+get-41513@lists.php.net to get a copy of this message
Hi folks! I am a used C programmer and now my company decide to switch every non performance critical web stuf to php. Since i am just a php beginner i have some questions i could not find anywhere! As you may know, C does not provide any kind of support for garbage collection, every thing you want to be done you have to tell (in C) by yourself. But in PHP i have no ideia about how it manages memory. for instance: In C: str = (char *) malloc(10u); if i decide to alloc new memory for str (just for explanation purposes), and i do: str = (char *) malloc(33u); i would be in trouble, cause the reference for the previous allocated pool of memory would be lost. The approach could be to save the previous references or use realloc. Now, my doubt: How PHP deals with this: $query = "select * from apm where id=3"; /* do my processing */ /* and set query to a new string */ $query = "Query done without errors"; What will happen with the previous allocated memory for $query? I don't like my application eating memory without releasing it after they are no need any more. May some one explain how to prevent such scenarios ? Thanks a lot for your time and cooperation. best regrads. Gustavo Rios

« previous php.general (#41513) next »