Client Side PHP in Internet Explorer

Share this article

While messing with PHP 5.0.0 figured it’s finally time to take at Wez Furlongs Activescript SAPI for PHP. Will the madness never end? ;)

In brief Microsoft provide a mechanism in Windows to “embed” scripting engines (e.g. PHP) and thereby allow execution of code in other languages. More information can be found at MSDN on Windows Script Interfaces.

For PHP the best place for information is the extensive README.

Here’s a quick example which should probably work first time on Win 2000 / Win XP.

1. Download PHP 5 and unzip it somewhere (e.g. C:php-5.0.0 – you need to create this directory!)

2. From a command prompt;


C:> cd php-5.0.0
C:php-5.0.0> regsvr32 php5activescript.dll

That’s it. Now the fun begins.

Create a (plain HTML) web page like;


PHP ActiveScript

$document->write('

Output generated by '. phpversion(). ' ['.php_sapi_name().']

');

$document->write('

Available objects

');

foreach ( array_keys($GLOBALS) as $global_var ) { if ( is_object($GLOBALS[$global_var]) ) { $document->write($global_var."
"); } }


View the page in IE and away you go (you should see a list of objects you’d normally use from Javascript).

Now all we need is Microsoft to bundle it with IE ;)

Back to reality, where is actually might be useful is if you want to write Windows sysadmin scripts in PHP.

Update: when posting this thought it would be obvious that this is highly insecure. Make sure you read all the comments below before trying it.

Harry FuecksHarry Fuecks
View Author

Harry Fuecks is the Engineering Project Lead at Tamedia and formerly the Head of Engineering at Squirro. He is a data-driven facilitator, leader, coach and specializes in line management, hiring software engineers, analytics, mobile, and marketing. Harry also enjoys writing and you can read his articles on SitePoint and Medium.

Read Next
Get the freshest news and resources for developers, designers and digital creators in your inbox each week