PHPScript

PHPScript is PHP's own ActiveScript interface. In practical terms, this means that you can use PHP from within any application that can host ActiveScript engines. The list of known hosts includes, and is not limited to:

  • Windows Scripting Host (WSH), cscript.exe/wscript.exe
  • "Classic" Active Server Pages
  • Microsoft Scripting Control, and by extension any application that loads that control
  • psvActiveScript Control for Delphi applications
  • Weaverslave an IDE
  • Kapsules a desktop widget engine

Installation

  • Download and install PHP 5
  • Download PHPScript and put it in your c:\\php5 directory
  • run regsvr32 c:\\php5\\php5activescript.dll

Usage

Windows Script Host

Create a .wsf file like this:

   <job id="test">
       <script language="PHPScript">
           $WScript->Echo("Hello");
       </script>
   </job>

or invoke your .php script directly from cscript.exe or wscript.exe using the //E:PHPScript option.

ASP (untested)

    <%@language=PHPScript %>
    <%$Response->Write("Hello"); %>

Script Controls

Set the language property to PHPScript

Script Components / IE

note: it is very dangerous to deploy PHPScript inside IE

Simply use <script language="PHPScript"> for your script tags.

Developers Notes

If you are developing code to run under PHPScript, you need to keep in mind the following differences from regular PHP:

  • echo doesn't have any practical effect. You need to call methods of the host to output information. You may still use output buffering etc., it just won't go anywhere if you flush it.

  • global objects added by the host are created as super-globals, so you need not reference them using the "global" statement.

  • PHPScript will not search for a default php.ini file. It will look instead for php-activescript.ini inside the folder of the .exe process that launched it.