How can the answer be improved? ESyndiCat is a powerful affordable web php directory software. Tons of directory plugins, top notch features that can help you build a powerful profitable directory site. ESyndiCat can be used as article directory software and business directory software.
- Setup a directory script Sell links in the directory for a premium In many of the directories following this model, virtually any link was accepted so long as they paid for a link.
- PhpMyDirectory is the leading website portal solution. Build and manage a powerful website with ease. Built using PHP and MySQL, phpMyDirectory can be used to create websites focused on a business directory, classifieds, link indexing and more!
- A versatile link directory script powered by PHP, Smarty, Jquery and mySQL that is versatile enough to be an article directory script, link directory script, classified ad site and much more.
- PHP Script Directory is a Free and Commercial Scripts of Popular Websites which provides unlimited category to post your requirements. Contact +633.
Active1 year, 6 months ago
In PHP, what would be the cleanest way to get the parent directory of the current running script relative to the www root? Assume I have:
Or just:
And I need to get
/relative/path/to/
with slashes properly inserted. What would you suggest? A one liner is preferred.EDIT
I need to get a path relative to the www root,
dirname(__FILE__)
gives me an absolute path in the filesystem so that won't work. $_SERVER['SCRIPT_NAME']
on the other hand 'starts' at the www root.Tatu Ulmanen
Tatu UlmanenTatu Ulmanen101k2828 gold badges165165 silver badges178178 bronze badges
13 Answers
If your script is located in
/var/www/dir/index.php
then the following would return:or
![Phpmydirectory Script Phpmydirectory Script](/uploads/1/2/5/2/125293131/838737810.png)
Edit
This is a technique used in many frameworks to determine relative paths from the app_root.
File structure:
index.php is my dispatcher/boostrap file that all requests are routed to:
Stuck on a differential equations question that's not in your textbook?
Chegg's differential equations experts can provide answers and solutions to virtually any differential equations problem, often in as little as 2 hours. Differential Equations Guided Textbook Solutions from Chegg Chegg's step-by-step differential equations guided textbook solutions will help you learn and understand how to solve differential equations textbook problems and be better prepared for class. Thousands of differential equations guided textbook solutions, and expert differential equations answers when you need them.
![Differential Differential](http://www.abt-photocopiers.co.uk/images/Canon_iRC1021i.jpg)
library.php is some file located an extra directory down and I need to determine the path relative to the app root (/var/www/).
There's probably a better way to calculate the relative path then
Mike BMike Bstr_replace()
but you get the idea.27.1k1010 gold badges7575 silver badges103103 bronze badges
As of PHP 5.3.0 you can use
__DIR__
for this purpose.Oct 30, 2010 Here comes the complete information: 'On 25 OCT 2010 I purchased the Office 2010 Language Pack German via Microsoft Office Online. On my computer I am running Microsoft Office 2010 which I purchased some months ago officially via Microsoft. Jul 19, 2013 Download Service Pack 2 for Microsoft Office 2010 Language Pack (KB2687449) 64-Bit Edition from Official Microsoft Download Center. Experience the best of Office with the latest versions of Word, Excel, PowerPoint, and more. Microsoft office 2010 deutsches sprachpaket download google. Jun 27, 2011 Service Pack 1 (SP1) for Microsoft Office 2010 Language Pack 32-bit Edition contains new updates which improve security, performance, and stability. Additionally, the SP is a roll-up of all previously released updates. Microsoft Office 2010 language packs enable people to convert the display language of Microsoft Office 2010 to the language of their choice. The language packs also feature other changes like the help and support system, proofing tools etc. Download Office 2010 language packs from direct download links given here. Jul 19, 2017 Microsft Office 2010 doesn't support the German Language Package for the download afterwards any longer. In the link I sent it says (freely translated): 'If you have Office 2010 (or any older version), language packages won't be supported and are not available any longer.'
![Scriptures Scriptures](/uploads/1/2/5/2/125293131/869841161.png)
The directory of the file. If used inside an include, the directory of the included file is returned. This is equivalent to dirname(__ FILE__).
See PHP Magic constants.
Charlie VieillardCharlie Vieillard
If I properly understood your question, supposing your running script is
This would give you the parent directory of your running script relative to the document www:
If you want the parent directory of your running script relative to server root:
Marco DemaioMarco Demaio20.7k3131 gold badges112112 silver badges148148 bronze badges
hanshans
Sliq9,4522121 gold badges8585 silver badges133133 bronze badges
BradBrad
Jordan Ryan MooreJordan Ryan Moore6,43722 gold badges2222 silver badges2727 bronze badges
Here is what I use since I am not running > 5.2
Double dirname with file as suggested by @mike b for the parent directory, and current directory is found by just using that syntax once.
Note this function only returns the NAME, slashes have to be added afterwards.
Phpmydirectory Script Fonts
AlexAlex7,23955 gold badges2626 silver badges6868 bronze badges
Vignesh KMVignesh KM
Try this. Works on both windows or linux server.
str_replace(','/',dirname(dirname(__FILE__)))
Download pes piala aff u19 terbaru untuk hp nokia asha 205 whatsapp. Apple Iphone Se Unlocked Phone 16 Gb Silver Amazon Com kamu sedang Butuh form tentang Apple Iphone Se Unlocked Phone 16 Gb Silver Amazon Com dan gambaran sekilas dari galery foto Apple Iphone Se Unlocked Phone 16 Gb Silver Amazon Com yang bagus dan yang baru banget di tahun 2018.
cestarcestar
collidoscopecollidoscope
This is a function that I use. Created it once so I always have this functionality:
JohnJohn
Goodhope Kudakwashe DhliwayoGoodhope Kudakwashe Dhliwayo
Got it myself, it's a bit kludgy but it works:
So if I have
Tatu Ulmanen/path/to/folder/index.php
, this results in /path/to/
.Phpmydirectory Script Hook
Tatu UlmanenPhpmydirectory Scripture
101k2828 gold badges165165 silver badges178178 bronze badges