Phpmydirectory Script
PhpMyDirectory is a leading and complete directory solution, which is easy to manage for building a powerful website. PhpMyDirectory builds with PHP and MySQL. Specially PhpMyDirectory focused on a business directory, Classifieds, link indexing and much more. Phpmydirectory php script modification Ended Hi, I require some customisations to the phpmydirectory script: 1. Move the 'Add Review' button on shop listing pages to the top right and make it more prominent. PHP Script Directory is a Free and Commercial Scripts of Popular Websites which provides unlimited category to post your requirements. Contact +633. PHP Business Directory is a responsive and SEO optimized php software for creating online business directory websites. The Easiest PHP Business Directory Script. Try the best website portal solution today. Easily manage members, process payments, publish content & more. Directory Lister is a simple PHP based script created to let you list the contents of a directory and all it's sub-directories and allow you to navigate there within. Just download and install Directory Lister to any web directory and have immediate access to all files and sub-directories under that directory.
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.
13 Answers
If your script is located in /var/www/dir/index.php
then the following would return:
or
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:
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 str_replace()
but you get the idea.
As of PHP 5.3.0 you can use __DIR__
for this purpose.
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.
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:
Phpmydirectory Script Hook
If you want the parent directory of your running script relative to server root:
Marco DemaioMarco DemaioHere 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.
AlexAlexTry this. Works on both windows or linux server.
str_replace(','/',dirname(dirname(__FILE__)))
Drive da impressora hp deskjet f4180 para windows 7. Download the latest driver, firmware, and software for your HP Deskjet F4180 All-in-One Printer.This is HP's official website to download drivers free of cost for your HP Computing and Printing products for Windows and Mac operating system.
Phpmydirectory Script Fonts
This is a function that I use. Created it once so I always have this functionality:
Got it myself, it's a bit kludgy but it works:
So if I have /path/to/folder/index.php
, this results in /path/to/
.