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

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.