Hello, there are many ways you can learn and write PHP, OOP is one of them and you are using one other, functional. Well in PHP functional variables inside functions have a scope only inside them, if you want to use them in a global manner you should declare that before using. Take a look athttp://php.net/manual/en/language.variables.scope.php
it a explains it a lot .

Tomashqooo you didn’t read my answer or the page I sent you. Ok let’s make it more clear (but PHP doc is our friend). You wrote

function printMenu()
{
echo($buffer);
}

$buffer has a scope only within printMenu function. It has nothing to do with the $buffer = ''; you declared outside it. If you want to use the global scope $buffer variable from within a function you must declare it first e.g.

function printMenu()
{
global $buffer;
echo($buffer);
}

This goes also for all the other functions that you are using a global variable inside a function without declaring it.