too long

I'm creating a Web Application, and I have the following line in my code:

<?php
    define('ROOT',$_SERVER['DOCUMENT_ROOT']);
?>

Everywhere i do an include() or so, I use this

<?php
    include_once(ROOT.'/path/to/script.php');
?>

What's the problem? When I install my application a folder, let's say /demo/ it won't work!

I assume the problem has to do with $_SERVER['DOCUMENT_ROOT'], but I can't figure it out. Where's my fault?

How can your application work if you install it to /demo, but request files from DOCUMENT_ROOT?

Either install your application to DOCUMENT_ROOT or set your 'ROOT' constant properly:

define('ROOT',$_SERVER['DOCUMENT_ROOT'] . '/demo');

In case you don't know folder name - use magic constant __DIR__:

define('ROOT', __DIR__);