PDA


View Full Version : global keyword ignored


dlloyd
11-30-2007, 01:38 AM
If i create a php_page pointing to a file with the following, there is no output. This works fine on CMPS v2.2.1 (vB 3.6) Any advice?


<?php
$test = "TEST!";
function Test()
{
global $test;
echo $test;
}
Test();

?>

Brian
11-30-2007, 01:29 PM
That is a known issue that can occur since the code is processed within a function. You should be able to correct that by looking in your includes/vba_cmps_include_top.php file for this code:
case 'php_file':
ob_start();
require($pages['template']);
$home[$modid]['content'] = ob_get_contents();
ob_end_clean();
break;


Replace with this:
case 'php_file':

// Processed outside of the function now

break;



Then look in your includes/vba_cmps_include_bottom.php file and add this code at the end, just before the closing ?> tag:
// Process PHP file pages here to avoid having to globalize variables
if ($pages['type'] == 'php_file' AND $vba_cusmodid)
{
ob_start();
require($pages['template']);
$home[$vba_cusmodid]['content'] = ob_get_contents();
ob_end_clean();
}