Loading a PHP file without hard-coding the path

Home Forums Tech Web Development Loading a PHP file without hard-coding the path

This topic contains 0 replies, has 1 voice, and was last updated by  Udar Gromov 13 years, 2 months ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #2278

    Udar Gromov
    Keymaster

    This is a simple way to include a PHP file without hard-coding either an absolute file location, or relative to a directory, where the file is loaded from:

    <?php
    require($_SERVER['DOCUMENT_ROOT'] .
    "wp-contentyou-pathyour-file-name.php");
    ?>

    This was tested on Windows IIS. On Unix machines you would need to change back slash to a front slash (‘/’)

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.