either define your variable as a global one:
function title()
{
global $title;
$title = "this is a test";
}
title();
echo $title;
or return it at the end of the function:
function title()
{
$title = "this is a test"
return $title;
}
echo title();
it's all to do with scope