How to Detect Internet Explorer with PHP

Detect IE (Internet Explorer) with this PHP snippet. It checks the User Agent.

function ae_detect_ie() { if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)) return true; else return false; } // Use the function and create a condition if(ae_detect_ie() == true){ echo "You're using IE"; }else{ echo "I'm glad you're not using IE"; }
Code language: PHP (php)


    1. Hello,

      Thank you for letting us know. Yeah I’m afraid the code is from 8 years ago. I think it might be no longer valid for the newer IE versions, as well as Edge.

      Best regards


  • Ricard Torres

Leave a Reply

Your email address will not be published. Required fields are marked *