alecks Posted December 16, 2007 Share Posted December 16, 2007 Having this problem, could someone offer a way to do this please The situation: function test1(){ global $b; echo $b; } function test(){ $b = "foo"; test1(); } test(); // nadda thanks Link to comment https://forums.phpfreaks.com/topic/81874-globals-in-nested-functions/ Share on other sites More sharing options...
rab Posted December 16, 2007 Share Posted December 16, 2007 function test1($b='Nothing?'){ echo $b; } function test(){ $b = "foo"; test1($b); } test(); Or function test1(){ global $b; echo $b; } function test(){ global $b; $b = "foo"; test1(); } test(); // nadda Link to comment https://forums.phpfreaks.com/topic/81874-globals-in-nested-functions/#findComment-415993 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.