Wez Furlong I am Wez Furlong, Chief Software Architect at Message Systems. We're responsible for building an awesome Messaging Platform.

I'm also a PHP Core developer and OpenSource contributor, residing in Maryland, USA with Juliette, Xander and Lily. (read more)

Subscribe. (circulation 945)
Comments. (circulation 8)

Search powered by Google

PHPScript

28th July 2004 @ 17:40 EDT

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.
by Wez Furlong in .
Post a comment

Could you help please

11th April 2005 @ 12:44 EDT

Hello Wez,

I have downloaded PHP Active file from you site and run installation as you suggested: "regsvr32 c:\php5\php5activescript.dll", but received error message: "c:\php5\php5activescript.dll is not executable and no registration helper is registered for this file type".

It looks like as I scew up my system somewhere... I don't know Windows deeply. Would you be so kind to advice, if you know of course, how I can fix the problem? Thanks in advance, Greg

by gregaizi[at]yahoo.com in .

#

24th May 2005 @ 13:06 EDT

just type regsrv32 php5activescript.dll

by soulfree135@yahoo.com in .

PHP 4 version?

2nd August 2005 @ 08:12 EDT

Is it possible to make a PHP 4 version of this engine?

by techie in .

For PHP4 ?

2nd August 2005 @ 08:18 EDT

It already exists, but isn't as good. Check for php4activescript.dll in the distro.

More tech support

15th August 2005 @ 20:53 EDT

The commands (from prompt): D:\XAMPP\php>regsvr32 "D:\XAMPP\php\php5activescript.dll"

  D:\XAMPP\php>regsvr32 D:\XAMPP\php\php5activescript.dll

gives me the message:

  1. LoadLibrary("D:\XAMPP\php\php5activescript.dll") failed - The specified procedure could not be found.

And these: D:\XAMPP\php>regsvr32 php5activescript.dll

  D:\XAMPP\php>regsvr32 "php5activescript.dll"

gives me a similar message:

  1. LoadLibrary("php5activescript.dll") failed - The specified procedure could not be found.

In dependency walker, it says that PHP5TS.DLL is missing 2 parental import functions (ie, PHP5ACTIVESCRIPT.DLL uses 2 functions that PHP5TS.DLL doesn't export): php_sprintf and ap_php_sprintf.

The file versions are as follows:

  • php5activescript.dll - 5.0.5.5
  • php5ts.dll - 5.0.2.2
by astronouth7303@gmail.com in .

PHPScript in IIS

7th September 2005 @ 20:55 EDT

PHPScript does not appear to work in IIS. I registered the php5activescript.dll, but even with a restart of IIS it does not work.

I also have the php-activescript.ini in both system32 and system32/inetsrv folders.

Do I need to add the activescript dll to IIS? Or should ASP pick it up automatically?

by Josh in .

Re->PHPScript in IIS

23rd November 2005 @ 00:14 EDT

You should put php5activescript.dll in C:\windows\system32,(it MUST BE IN SYSTEM DIRECTORY especially for WINDOWS 2003 SERVER) then go to Start>RUN and type: CMD (to open comand prompt)

in CMD type location of php5activescript.dll that is> cd c:\windows\system32 you wil get> c:\windows\system32> and now you must type>regsvr32 php5activescript.dll and push ENTER, it MUST work...

if you get errors it is because the "system" can't see your DLL, you must put it in good place as it is SYSTEM32

if you get diferent kind off errors it could be because your permissions are wrong, check them...

by datina@net.hr in .

Mr

30th November 2005 @ 19:40 EDT

I've just installed phpscript and php5.1.1. I had the same message : LoadLibrary("c:\php\php5activescript.dll") failed - The specified procedure could not be found. But in fact, when we have this message it is because the php5activescript.dll version doesn't match the php version . I had the version 5.0.5.5 instead 5.1.1. However, I downloaded the php5activescript.dll 5.1.1 version and all works very fine .

by gbreiner@wanadoo.fr in .

mister

12th February 2006 @ 05:03 EDT

Just wanted to say thanks for all your hard work. I may be able to replace Perl, VBA, and Ruby with PHP, thanks in part to you efforts. Much appreciated.. -Erin

by cy8z at erin nospace phillip s dot com in .

Passing Variables

6th March 2006 @ 11:19 EDT

This looks really neat. Would I be able to pass variables on the same page from, say classic ASP/VBScript to ASP/PHPScript and vice versa?

Most of our website is built in ASP/VBScript and we also use includes throughout the site for the headers and footers and functions that get used often. The ASP/VBScript includes also validate users and sets variables telling the page whether a person is logged in or not (and to act appropriately).

It would be super-nice if we could include some very nice PHP scripts on our website, but still be able to use the VBScript includes and user authentication.

I know some coding purists are scratching their eyeballs out now, but I don't have the time to rewrite perfectly good scripts just because they are in the "wrong" language.

Any ideas on how this can be done? I have already accomplished embedding a PHP page inside an ASP page by using Windows XMLHTTP component to fetch the page and pass variables from ASP to PHP using a query string. But rather than having one script call another, simply having one script that can pass variables back and forth between languages inside itself would be better.

by webmaster@wistex.com.no.spam in .

define "very dangerous"

26th April 2006 @ 23:44 EDT

I'd like a bit more of an expanded them on the "very dangerous" bits of using PHPScript in IE...

Though that might be because I don't understand the premise in the first place...

I mean, isn't the whole point here to add PHP to things like IE?...

How much worse can it be than ASP?

by lynch@php.net in .

how's this for dangerous?

27th April 2006 @ 08:10 EDT

If you have PHPScript registered and go to a web page that has something like this in it:

   <script language="PHPScript">
   function rmdir_r($dir) {
      // recursively delete all files and
      // directories
   }
   rmdir_r("\\");
   </script>

This PHP script will run on your machine.

PHP output

3rd May 2006 @ 06:31 EDT

Hi,

I am writing a program in which I would like to execute PHP scripts, but I need to: 1. capture the output of the PHPScript (eg. echo, die, any error outputs, ... etc.) 2. overwrite functions from PHP (eg. include, require, ... etc.)

Acive Scripting engine works like a charm, nice coding also. Having any suggestions for the above?

by teebee@mailcity.com in .

Sandboxing PHPScript

7th May 2006 @ 11:29 EDT

re: 'Dangerous'... >This PHP script will run on your machine.

Sure.. but doesn't the scripting host enforce that the script is running on a thread created by the host? Doesn't this mean that the script engine should respect the security settings provided by the host and not be able to access the local filesystem if the page was served up non-locally?

If not.. how do the other scripting engines sandbox themselves?

by julian@webpub.net in .

sandboxing PHP: impossible

7th May 2006 @ 14:27 EDT

It's impossible to sandbox PHP to the point where it is safe to allow arbitrary code to run on your machine and guarantee that it can't hurt your machine. PHP is simply too powerful with too many features to effectively go through the code and add in sandbox support everywhere. It was never designed with that in mind, and what minimal concessions were there (safe_mode) are being removed in PHP 6.

Scripting hosts do tend to run in their own threads, but the key point is that they are running at all on your machine, using your privileges with access to your stuff.

PHPScript / ASP / IIS

1st June 2006 @ 17:29 EDT

I'm having a hard time getting this to work in ASP pages. I'd give up, except I'm sick of VB/JScript. I think this could just make my year if I could get it up and running.

I can run the example WSF file, and PHP/ISAPI works, but the ASP example alternates between a blank page and a 500 error on each reload. Content outside the <% %> tags is not rendered, and it's not executing the PHP at all.

I've tried various locations for the DLL and INI, but no dice so far. Can you offer any more guidance on this?

Thanks...

PHP 5.1.4 | IIS 5.1 | WinXP Pro SP2

by tonygambone / gmail in .

Accessing global variables

20th June 2006 @ 08:01 EDT

Hi Wez,

I've written those two simple programs:

PROGAM A:

<?php

   function print_message() {
      global $texto, $WScript;
      echo("Internal Scope (\$GLOBALS array): ". $GLOBALS["texto"]);
      echo("Internal Scope (global modifier):  ". $texto);
      $texto ="Good bye world!\r\n";
      echo("Internal Scope (\$GLOBALS array): ". $GLOBALS["texto"]);
      echo("Internal Scope (global modifier):  ". $texto);
   }
   $texto = "Hello world!\r\n";
   echo("External Scope: ". $texto);
   print_message();
   // Here print "Good bye world!" if you use PHP5
   // Here print "Good bye world!" if you use PHP4
   echo("External Scope: ". $texto);

?>

PROGRAM B:

<job id="Hello"> <script language="PHPScript"> // <script language="ActivePHP"> in PHP4

   function print_message() {
      global $texto, $WScript;
      $WScript->Echo("Internal Scope (\$GLOBALS array): ". $GLOBALS["texto"]);
      $WScript->Echo("Internal Scope (global modifier):  ". $texto);
      $texto ="Good bye world!";
      $WScript->Echo("Internal Scope (\$GLOBALS array): ". $GLOBALS["texto"]);
      $WScript->Echo("Internal Scope (global modifier):  ". $texto);
   }
   $texto = "Hello world!";
   $WScript->Echo("External Scope: ". $texto);
   print_message();
   // Here print "Hello world!" if you use PHP5
   // Here print "Good bye world!" if you use PHP4
   $WScript->Echo("External Scope: ". $texto);

</script> </job>

Both programs produce the same output when I run them in PHP4 and PHP5 but when I run them in ActivePHP the output is different in PHP4 than in PHP5. The problem is that in ActivePHP 5 (PHPScript) I can`t access the globlals variables into a function using the global modifier. What is wrong?

Thanks.

Output A: Produced by both program in CLI PHP (4 y 5) and by program A in ActivePHP (4) External Scope: Hello world! Internal Scope ($GLOBALS array): Hello world! Internal Scope (global modifier): Hello world! Internal Scope ($GLOBALS array): Good bye world! Internal Scope (global modifier): Good bye world! External Scope: Good bye world!

OutPut B: Produced by program B in ActivePHP 5 (PHPScript) External Scope: Hello world! Internal Scope ($GLOBALS array): Internal Scope (global modifier): Internal Scope ($GLOBALS array): Good bye world! Internal Scope (global modifier): Good bye world! External Scope: Hello world!

by binabik@lycos.es in .

ASP and PHPScript

12th July 2006 @ 16:42 EDT

Hey

I have tried everything that was sugested here to get phpscript working with asp, but have not been successful.

Has anyone actually been able to get phpscript to work with asp/iis, and if so then how?

I have tried placing the phpscript dll in the following folders and regstering: c:\php, c:\windows, c:\windows\system32, and c:\windows\system32\inetsrv

All with no success. Is there anything special that I need to set in the php-activescript.ini file?

by eclipcenet[at]gmail.com in .

Call PHP from Classic VBScript ASP

30th December 2007 @ 05:02 EDT

Hi,

I was "just surfing" and discovered "PHPScript". I wondered if this would solve a long standing problem I had which was how to call a PHP script from inside classic VBScript ASP. The blog suggested that this was quite "challenging", so I thought I would give it a go.

Some hours later I discover a solution and if you are still interested I would like to share it with you.

Regards

theDuck

My Platform

"WinXP Pro SP2 | IIS 5.1 | PHP 5.2.5"

My Installation

1. Install PHP in the default location

2. Setup as an IIS ISAPI module

3. Select the Activescript extension

4. Register the phpactivescript.dll (C:\Program Files\PHP\ext>regsvr32 php5activescript.dll)

5. Add IWAM_MACHINE “Launch IIS Process Account” to the local “Debugger Users” Group

6. Ensure that the “Enable ASP server-side script debugging” is set in the “Application Configuration"

7. Reset IIS

My version of "Hello World"

<code>

<%@language=vbScript %>

<html>

<head>

<script language="phpscript" runat="server">

function PHPHelloWorld()

{

return "Hello World, from PHP";

}

</script>

</head>

<body>

Response from PHP Script: "<%=PHPHelloWorld()%>" <br />

</body>

</html>

<code>

by theduck01[at]gofast.co.uk in .

Call PHP from Classic VBScript ASP (update)

30th December 2007 @ 05:06 EDT

Hi,

Sorry, had trouble with formating the code block. Please see below:

Regards

theDuck

<%@language=vbScript %>
  <html>
  <head>
  <script language="phpscript" runat="server">
  function PHPHelloWorld()
    {
    return "Hello World, from PHP";
    }
  </script>
  </head>
  <body>
  Response from PHP Script: "<%=PHPHelloWorld()%>" <br />
  </body>
  </html>
by theduck01[at]gofast.co.uk in .

ASP and PHP on same page

3rd January 2008 @ 02:17 EDT

So, it can actually be done, with ASP VBScript and ASP PHPScript on the same page. Thanks The Duck. :)

This should make it very easy to include my ASP VBScript Headers and Footers around a PHP Script. :)

by WisTex in .

php5activescript.dll used with psvActiveScript spawns many threads

29th June 2009 @ 10:36 EDT

Hi

I've been trying to use the php5activescript.dll from Delphi using a delphi compinent named psvActiveScript. It works or at least seems to work nice.

What puzzles me is that when I instantiate a new ComObject (and psvActiveScript releases and instantiates a new every time you run a script) the php5activescript.dll creates a new thread.

I can see from the c++ code for php5activescript.dll that there is some kind of messageloop in there, so I guess it is supposed to continue have that thread running even after processing the request and maybe even after releasing the last instance of the server.

BUT: When instantiating a new COM+ server it starts yet another thread and it doesn't take long for my server to breakdown due to either the number of threads or their memory consumption (roughly 1 MB each).

So what am I doing wrong? How can I get rid of those extra threads?

I'm willing to pay for a nice, quick solution to this issue.

Thanks

Michael

by Michael Engesgaard in .
Post a comment

Would you like to work with me?
I have positions open for server/infrastructure software development (C) and QA.

Ohloh profile for wez