The xxx.php shown in the browser will output the template file, without the values for $title. Can somebody: (1) explains what happen? (2) suggest what I should do to tackle the problem? Suppose I want to put xxx.php anywhere in my site.
$_SERVER['DOCUMENT_ROOT'] is an automatic reference to the root directory for the website the file is being served from, so all you need to do is tack file paths (to web accessible stuff, that is) onto the end of it. saves a little time over trying to figure out include('/home/myusername/www/sitename/new/template.php') or whatever other weird full paths you might be needing to use otherwise.
(Using include() on remote files is a big security no-no, and actually probably is why it won't pull that variable name in there. Otherwise what would stop you from using include('http://www.example.com/some/path/to/a/config.php'); and stealing someone else's DB information?)