ID:               33386
 User updated by:  csaba at alum dot mit dot edu
 Reported By:      csaba at alum dot mit dot edu
 Status:           Open
 Bug Type:         COM related
 Operating System: Win XP Pro
 PHP Version:      5.1.0b1
 New Comment:

Sigh...the expected results are actually:
 func one
 func one
 func two
 func two
 func one
 func two


Previous Comments:
------------------------------------------------------------------------

[2005-06-17 16:38:14] csaba at alum dot mit dot edu

Description:
------------
When I use a PHP class with the MSScriptControl.ScriptControl object
and want to invoke a function in the class from within the
ScriptControl, I always get the last function from the class regardless
of which one I try to invoke (provided I've used the name of ANY
function in the class - see note on actual result).

If I implement the same thing in VB5 (VBScript with VB5CCE, actually),
this problem does not happen.  The code for it is also short and I am
happy to provide it, if it would be useful

Csaba Gabor from Vienna

Reproduce code:
---------------
<?php
// Demonstrates that you will get the last function when
// calling to a PHP class via MSScriptControl
class twoFuncs {
    public function func1() { echo " func one\n"; }
    public function func2() { echo " func two\n"; }
}
$ciTF = new twoFuncs;

$oScript = new COM("MSScriptControl.ScriptControl");
$oScript->Language = "VBScript";

// the object, within the script control, is referred to as tFA
// that final true means that the tFA. may be omitted within the script
control
$oScript->AddObject ("tfA", $ciTF, true);
foreach (array(1,2) as $i) {
    $oScript->ExecuteStatement ("tfA.func$i");
    $oScript->ExecuteStatement ("func$i");
}
$oScript->AddObject ("tfB", $ciTF);
foreach (array(1,2) as $i)
    $oScript->ExecuteStatement ("tfB.func$i");
?>

Expected result:
----------------
I expect to see:
 func one
 func two
 func one
 func two
 func one
 func two


Actual result:
--------------
I see func two repeated 6 times.
In other words, regardless of what function I name, only the last
defined function in the PHP class is executed, which is incorrect.

However, if I attempt to call a function that isn't there, such as
$oScript->ExecuteStatement ("tfA.func3");
then PHP will (correctly) throw an error

This to me says that PHP gets as far as determining whether the
function is there or not, but then it messes up on the indirection.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=33386&edit=1

Reply via email to