<?php include_once $modx->config['base_path'].'template.php'; $a='a variable'; template(); // I'm trying to display the result ?>
<?php
function template(){ // This was meant to be a display function
global $a;
echo 'I\'m calling '.$a;
}
?>
I’m calling a variable // test outside modx
I’m calling // result in modx
<?php
global $a;
function template(){ // This was meant to be a display function
global $a;
return 'I\'m calling '.$a;
}
$a = 'a variable';
return template($a);
?>
<?php
function template($a){ // This was meant to be a display function
return 'I\'m calling '.$a;
}
$a = 'a variable';
return template($a);
?>
<?php $a = 'a variable'; return template($a);
<?php $a = 'a variable'; echo template($a);
file: snippet.inc.php
<?php
global $a; // different with a standalone php file
$a = 'a variable';
return template();
?>
file: template.php
<?php
function template(){ // This was meant to be a display function
global $a;
echo 'I\'m calling '.$a;
}
file: snippet.inc.php
<?php
global $a; // different with a standalone php file
$a = 'a variable';
echo template(); // I think this one, since the "echo" doesn't immediately end execution the rest of the codes.
?>
file: template.php
<?php
function template(){ // This was meant to be a display function
global $a;
return 'I\'m calling '.$a;
}