Jarid Posted August 11, 2010 Share Posted August 11, 2010 I am trying to use the variable $RATETHESE to include an array into file A. The array is in file B. PhP File A include_once(dirname(__FILE__) . '/PhpFileB.php'); global $RATETHESE; $VALID_RATING_IDS = $RATETHESE; Php File B $RATETHESE = "array("1", "2");" For some reason it is printing the array on the page, and the array is not being used to run the script. Did i do anything wrong? Quote Link to comment https://forums.phpfreaks.com/topic/210397-how-can-i-use-a-variable-to-get-an-array-from-another-php-file/ Share on other sites More sharing options...
trq Posted August 11, 2010 Share Posted August 11, 2010 File B should be.... $RATETHESE = array(1, 2); Why you have the quotes is beyond me. Quote Link to comment https://forums.phpfreaks.com/topic/210397-how-can-i-use-a-variable-to-get-an-array-from-another-php-file/#findComment-1097884 Share on other sites More sharing options...
PFMaBiSmAd Posted August 11, 2010 Share Posted August 11, 2010 Also, the global keyword has absolutely no meaning except when used inside of a function definition, is not doing anything in the code you posted, and the line using it should be removed. Quote Link to comment https://forums.phpfreaks.com/topic/210397-how-can-i-use-a-variable-to-get-an-array-from-another-php-file/#findComment-1097888 Share on other sites More sharing options...
Jarid Posted August 11, 2010 Author Share Posted August 11, 2010 The php script printed $RATETHESE = array("1", "2") on the page it was included on. This does not happen if i replace $VALID_RATING_IDS = $RATETHESE; with $VALID_RATING_IDS = array("1", "2") Is there anyway i can include the array from PhpFileB.php into the script without it being printed on the page? Quote Link to comment https://forums.phpfreaks.com/topic/210397-how-can-i-use-a-variable-to-get-an-array-from-another-php-file/#findComment-1097895 Share on other sites More sharing options...
trq Posted August 11, 2010 Share Posted August 11, 2010 Is there anyway i can include the array from PhpFileB.php into the script without it being printed on the page? Is all this code within <?php ?> tags? Post your ACTUAL code. It won't print if done properly. Quote Link to comment https://forums.phpfreaks.com/topic/210397-how-can-i-use-a-variable-to-get-an-array-from-another-php-file/#findComment-1097898 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.