ActiveScript

本节将介绍有关 ActiveScript 安装需要注意的方面。

ActiveScript 是一个只运行在 Windows 下的 SAPI,可以在任何兼容 ActiveScript 的主机上使用 PHP 脚本,例如 Windows Script Host、ASP/ASP.NET、Windows Script Components 或 Microsoft Scriptlet control。

PHP 5.0.1 以后,ActiveScript 被移动到了PECL 库。可以从 PHP 下载页面或者 http://snaps.php.net/ 下载此 PECL 扩展的 DLL 文件。

注: 应该首先阅读手动安装步骤

PHP 安装完成后,应该下载 ActiveScript DLL(php5activescript.dll)并将其放入 PHP 主目录(例如 C:\php)。

准备好全部所需文件后,必须在系统中注册 DLL。做法是打开命令提示行窗口(位于开始菜单),然后输入类似 cd C:\php 的命令进入 PHP 目录,最后输入 regsvr32 php5activescript.dll 注册该 DLL。

要测试 ActiveScript 是否正确工作,请创建一个新文件,命名为 test.wsf(这个扩展名很重要)然后输入:
<job id="test">

 <script language="PHPScript">
  $WScript->Echo("Hello World!");
 </script>

</job>
保存并双击这个文件。如果您看到一个小窗口,内容为“Hello World!",说明安装成功。

注: 在 PHP 4 中,该引擎被命名为“ActivePHP”,如果使用 PHP 4,应该将上例中的“PHPScript”替换为“ActivePHP”。

注: ActiveScript 不使用默认的 php.ini 文件,而仅在调用它的 .exe 文件所在目录中寻找。如果想装载 PHP 扩展等,应该创建 php-activescript.ini 并将其放入那个目录。


add a note add a note User Contributed Notes
maflorez at cognox dot com
16-Oct-2006 01:43
Other option is this:
Copy this text, save with extension .reg and execute.

***** Begin of file don't include
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.phs]
@="PHPScript"

[HKEY_CLASSES_ROOT\PHPScript]
@="PHPScript"
"EditFlags"=dword:00000000
"AlwaysShowExt"=""
"BrowserFlags"=dword:00000008

[HKEY_CLASSES_ROOT\PHPScript\shell]
@="Run"

[HKEY_CLASSES_ROOT\PHPScript\shell\Run]

[HKEY_CLASSES_ROOT\PHPScript\shell\Run\command]
@="wscript.exe //E:PHPScript \"%1\" \"%2\""

[HKEY_CLASSES_ROOT\PHPScript\shell\Run\ddeexec]

[HKEY_CLASSES_ROOT\PHPScript\shell\Run\ddeexec\Application]
@="wscript"

[HKEY_CLASSES_ROOT\PHPScript\shell\Run\ddeexec\Topic]
@="System"
***** End of file don't include
garfiel_fr at tiscali dot fr
12-May-2005 12:06
There is another way to execute a PHP ActiveScript:

1/ In explorer, open menu "Tools/Folder Options"
2/ Go to tab "File Type"
3/ Click on "New" button and enter a file extension ( PHS for my sample ), you can also select "PHPScript" in "Advanced" button. Then OK, a new file extension is registered.
4/ In tab "File Type" select the new extension and click on button "Advanced". A new dialog box is open.
5/ Click on "New" button and fill edit box with:
  Action: Run
  Application to use: C:\WIN2K\system32\wscript.exe //E:PHPScript "%1" "%2"

That's all !!

Now, your code don't need XML tag at the begining. Hello work in test.phs will be:

$WScript->Echo("Bonjour le monde !");