calmchess Posted February 20, 2009 Share Posted February 20, 2009 I have a main.php file and an include_once php file i'm trying to call a function in the main.php file from the include_once file because i only want the function to run once. problem is test(); function never fires when i load the page....i can get varaiables from the include file so i know i have paths correct...can sombody help me fire the function? Link to comment https://forums.phpfreaks.com/topic/146184-function-being-called-from-include_once-not-being-called/ Share on other sites More sharing options...
samshel Posted February 20, 2009 Share Posted February 20, 2009 please post some code...have u included the file after you have defined the function? Link to comment https://forums.phpfreaks.com/topic/146184-function-being-called-from-include_once-not-being-called/#findComment-767488 Share on other sites More sharing options...
calmchess Posted February 20, 2009 Author Share Posted February 20, 2009 the include file has this $var0 = "test"; $var1 = "test2"; test(var0); the main file has include_once(test.php); function test($var2){ echo $var2; } Link to comment https://forums.phpfreaks.com/topic/146184-function-being-called-from-include_once-not-being-called/#findComment-767497 Share on other sites More sharing options...
samshel Posted February 20, 2009 Share Posted February 20, 2009 you are calling function before you define it..try this function test($var2){ echo $var2; } include_once(test.php); Link to comment https://forums.phpfreaks.com/topic/146184-function-being-called-from-include_once-not-being-called/#findComment-767500 Share on other sites More sharing options...
calmchess Posted February 20, 2009 Author Share Posted February 20, 2009 after throwing a test file togeather i've determined that there is something else wrong with the code and stops the include_once from firing the function....disregard this post there is nothing wrong with firing a function from an include file just something wrong with my code. Link to comment https://forums.phpfreaks.com/topic/146184-function-being-called-from-include_once-not-being-called/#findComment-767510 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.