|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-11-26 14:53 UTC] sonya at look-for-it dot de
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 05:00:01 2025 UTC |
Description: ------------ I was not able to continue my bug report #43022 because it's set to bogus. But it's still about different behaviour of $GLOBALS within SOAP. I try to make it more clear in this bug report. Reproduce code: --------------- Please create a file inc.php ---------------------------- inc.php ---------------------------- class TestClass1 { public $testvar1; function TestClass1() { $this->testvar1 = 100; } } $TestClass1 = & new TestClass1(); // GLOBALS['TestClass1"] is NOT set while executing via SOAP // GLOBALS['TestClass1"] is set while executing via browser class TestClass2 { public $testvar2; function TestClass2() { global $TestClass1; $this->testvar2 = $TestClass1->testvar1; } } $TestClass2 = new TestClass2(); ---------------------------------------------- then compare $GLOBALS['TestClass1'] while executing in Browser -------------------------------------- test.php -------------------------------------- require_once 'inc.php'; print '<pre>'; print_r ($GLOBALS['TestClass1']); print '</pre>'; -------------------------------------- and while executing via SOAP -------------------------------------- server.php -------------------------------------- function testGlobals() { global $TestClass1, $TestClass2; require_once 'inc.php'; return serialize($GLOBALS['TestClass1']); } -------------------------------------- client.php -------------------------------------- ini_set("soap.wsdl_cache_enabled", "0"); $client = new SoapClient("test.wsdl", array('trace'=> 1, exceptions'=> 0)); print '<pre>'; print_r (unserialize($client->testGlobals())); print '</pre>'; ---------------------------------------------- Expected result: ---------------- Expected the same result returned by soap service and displayed in browser. $GLOBALS assignment has to be the same. Actual result: -------------- You will find that TestClass1 is assigned to $GLOBALS when executing via Browser and not assigned when executing the _same_ code via SOAP. Unless you pass the object by value in inc.php. My question is - why there is different behaviour with the same code? Thank you.