|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-12-18 08:36 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 15 22:00:01 2025 UTC |
Description: ------------ Hi Master! I used php5.2 to write a class for some needs, I was surperised to find the static variable worked in an abnormal way, so I need you help to test it! --- test.php <?php class JavaBridgeLoader { private static $configedFlag = false; const jar_path = "jar/"; public static function preConfig(){ var_dump(self::$configedFlag); if(self::$configedFlag == false){ //exec('java -jar '. self::jar_path. '"JavaBridge.jar" SERVLET:8080'); self::$configedFlag = true; } var_dump(self::$configedFlag); } } JavaBridgeLoader::preconfig(); ?> I expect for the result is "bool(false) bool(true) at the first time, And then: bool(true) bool(true) at the second time" I am not a phper, I am a java liker and want to learn the php lanugage, I dont know why it can not performence like java performence, So I report this bug! Thank you and hoping for you responsing... And best Regards to you all! Reproduce code: --------------- <?php class JavaBridgeLoader { private static $configedFlag = false; const jar_path = "jar/"; public static function preConfig(){ var_dump(self::$configedFlag); if(self::$configedFlag == false){ //exec('java -jar '. self::jar_path. '"JavaBridge.jar" SERVLET:8080'); self::$configedFlag = true; } var_dump(self::$configedFlag); } } JavaBridgeLoader::preconfig(); ?> Expected result: ---------------- bool(false) bool(true) ---- the first time bool(true) bool(true) ---- the second time Actual result: -------------- bool(false) bool(true) ---- the first time bool(false) bool(true) ---- the second time