
Originally Posted by
salman1karim
I dont know how can i define root directory or server path in php and as well how to use it?
It's already defined: $_SERVER['DOCUMENT_ROOT']
Depending on your server configuration, there may or may not be a trailing slash. In general, there is not; but you never know. You can do something like this:
PHP Code:
<?php
define( "ROOT",rtrim( $_SERVER['DOCUMENT_ROOT'],'/' ) );
include ROOT."/includes/menu.php";
which removes the slash if it exists. The constant also has the added benefit of being much easier to type.
Bookmarks