PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
back when variables and the strings the pointed to had to be allocated, it was better to reuse variable names. I still constantly reuse the same name (in my case I use $sql for a SQL query) because I can see each instance where it is initialized and can easily search for all my SQL (selects, insert, deletes, etc) by looking for my variable name.
If you were to actually make each variable a unique name, then you would in essence be allocating many block of memory to hold strings that get used once.
i think the same too, it's like buying a box, then filling it, then after using it leave it there making space and then buy another box just to fill it again with something else, not using the first box and not discarding everything that was inside in it before...
since heap allocation has a worst-case complexity of O(log N) you have to grab a lot of memory to notice noteworthy changes. Probably more than the common single php-script does.
What's the memory limit set in your php.ini? What's the total amount of phsical memory your computer has and how much swapping is involved? PHP caches a lot and also note the guaranteed resolution of the timer you're going to use.
After all as long as Moore's law holds I pay only little attention to anything that is measured in splitseconds and has a complexity less than polynominal