Hello @kartik,
It is not working because you have to declare which global variables you'll be accessing:
$data = 'My data';
function menugen() {
global $data; // <-- Add this line
echo "[" . $data . "]";
}
menugen();
Otherwise you can access it as $GLOBALS['data'].
Hope it helps!!
Thank you!!