Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Programming»PHP»Find the Document Root using PHP Script

    Find the Document Root using PHP Script

    By RahulSeptember 28, 20171 Min Read

    DOCUMENT ROOT is the path where application is stored on file system. In some application’s we need to use absolute path of any file or script in our php script, While development we really don’t know where application will be hosted on server. In that case we can use php function getenv() to get the document root of application dynamically using PHP script.

    Advertisement
    <?php
    //PHP Script to find Document Root of Application
    
    $docroot = getenv("DOCUMENT_ROOT");
    echo $docroot;
    
    ?>
    

    As per above PHP script actual DOCUMENT ROOT of application will be stored in $docroot variable which can be used further in application.

    document root getenv PHP script
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    Installing PHP on Pop!_OS

    How to Install PHP 8.x on Pop!_OS

    Managing Dependencies with Composer: A Beginner’s Guide

    Checking If a Command Succeeded in Bash Using the `$?` Special Variable

    Add A Comment

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • How to Split Large Archives in Linux using the Command Line
    • System.out.println() Method in Java: A Beginner’s Guide
    • Split Command in Linux With Examples (Split Large Files)
    • Test Your Internet Speed from the Linux Terminal
    • 11 Practical Example of cat Command in Linux
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.