PHP Foreach Preserves Last Item

I thought I’d blog this because it’s something that comes as a surprise to me, so it may come as a surprise to you. Let’s consider this code: http://pastebin.com/mxsjMdij

The second time the loop runs it actually preserves the value of the “$app” variable, and thus triggers the if statement’s isset() function to true.

This issue caught me for a loop for a while, but I guess now I know…. interesting PHP….

Check if a website is running Magento Community or Enterprise Edition

To check if a website is running Magento the first thing you want to do is view the page source and search for “Varien”. If you find a match then the website is *probably* running Magento. If you do not match anything, next view the source of the JS files and look for “Varien”. Some websites merge their javascript files into one file, so that should be easy.

After you know if the website is running Magento, you can detect if a website is running Magento Enterprise Edition by hitting *website_base_url*/giftcard/customer in your browser. If you get a 404 Page Not Found error then that means they are NOT running MEE (Magento Enterprise Edition). If you get redirected to a login page that means they ARE most likely running MEE.

You can get browser extensions like Chrome Sniffer that will also tell you if they are running Magento, however the above method is great if you need to do it programmatically for some reason.