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….
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.