PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, May 17, 2022

[FIXED] How to get document root path in PHP with CLI?

 May 17, 2022     php     No comments   

Issue


echo __DIR__;

" How to get document root path in PHP from any subdirectory using command line?

my directory structure--

/dinesh
       /data
            /asset

Suppose my root directry is /dinesh

and currently my script in asset but I require document root path till /dinesh only

by using command line php CLI

How will I get this?

I have tried DIR and FILE but that give path till asset and one more thing that dinesh is my local root folder name that is changeable when I move my code to other server"


Solution

echo($_SERVER["PWD"]); its working



Answered By - Dinesh Ghule
Answer Checked By - Mildred Charles (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing