Search code examples
phpactivex

Is it possible to use Activex in PHP?


Is it possible to use ActiveX in PHP? I want to use an ActiveX in my server-side PHP code.


I'm trying to load an Activex in my PHP code, As I know this can be done with COM function in PHP, so I try to access my methods as below:

<?PHP
$active = new COM("sswATL.crypto");
//------------------------

$pass = "pincode";

$ret = $active->init( $pass , $retVal);

if($retVal == 0){ 
   print "Login successfully";
}
elseif($retVal == 4){

   print "Token is not present";
} 
else
{
   $errMsg = "Login failed : "; 
   print $errMsg;
  }
?>

but I got this error:

Fatal error: Uncaught exception 'com_exception'
with message '<b>Source:</b> Unknown<br/><b>Description:</b> Unknown'
in C:\my\php\file\path.php
Stack trace:
#0 C:\my\php\file\path.php: com->init('pincode', NULL)
#1 {main}
thrown in C:\my\php\file\path.php on line 7

init method is declared as:

int init(string s,int &num);

any ideas?


Solution

  • Use the COM class for calling ActiveX: http://cn.php.net/manual/en/book.com.php

    function clsMSWord($Visible = false) { 
        $this->handle = new COM("word.application") or die("Unable to instanciate Word"); 
        $this->handle->Visible = $Visible; 
    }