By default VS is not made to run PHP, but you can do it with extensions:
You can install an add-on with the extension manager, PHP Tools for Visual Studio.
If you want to install it inside VS, go to Tools > Extension Manager > Online Gallery > Search for PHP where you will find PHP Tools (the link above) for Visual Studio. Also you have VS.Php for Visual Studio. Both are not free.
You have also a cool PHP compiler called Phalanger:

If I’m not mistaken, the code you wrote above is JavaScript (jQuery) and not PHP.
If you want cool standalone IDE’s for PHP: (Free)
- Netbeans: https://netbeans.org/downloads/start.html?platform=windows&lang=en&option=php
- Eclipse: http://www.eclipse.org/downloads/packages/eclipse-php-developers/heliosr