1--TEST-- 2Static variable with throwing initializer 3--FILE-- 4<?php 5 6function foo($throw) { 7 static $a = $throw ? (throw new Exception('Throwing from foo()')) : 42; 8 return $a; 9} 10 11try { 12 var_dump(foo(true)); 13} catch (Exception $e) { 14 echo $e->getMessage(), "\n"; 15} 16var_dump(foo(false)); 17 18?> 19--EXPECT-- 20Throwing from foo() 21int(42) 22