Phpmydirectory Script

Hello, It's been a while since I posted about phpMyDirectory. A new version has been released, phpMyDirectory 1.3.1. This script really is becoming more and more versatile. Top PHP based SEO friendly Business Directory Script. Download Nulled Business Directory Script. Reviews, Features and Installation guide. Find the hottest free and commercial php scripts available on the web - submit your script for free! PhpMyDirectory is now leading business Directory Script. Download Nulled version of phpMyDirectory. Know about reviews, Features and Installation Guide. PhpMyDirectory demo is a full featured demo of the software, including the front end, members area, and control panel.

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 Ulmanen
101k28 gold badges165 silver badges178 bronze badges

13 Answers

If your script is located in /var/www/dir/index.php then the following would return:

Operation Systems: Microsoft Windows 7, Windows Vista, Windows Xp Released: Nov 15, 2012 Version 14.5.1 File name: setup_full_SJ2410_140_052.exe File Size: 151.42 Mb HP Scanjet Basic Feature Driver This is the minimum driver required for basic WIA functionality (USB only). Operation Systems: Microsoft Windows 8 (32-bit), Microsoft Windows 8 (64-bit), Microsoft Windows 8.1 (32-bit), Microsoft Windows 8.1 (64-bit), Microsoft Windows 7 (32/64bit), Windows Visra (32/64bit), Windows Xp File name: setup_basic_G2410.exe Released: Aug 9, 2013 Version: 1.1 File Size: 1.52Mb Categories Tags,,,,,,, Post navigation. Hp g2410 scanner driver for windows 10 64 bit. Scanning can also be done with a variety of 3rd party scanner enabled applications. This driver enables scanning with the Windows Photo Gallery on Windows Vista or the Scanner and Camera Wizard on Windows XP. HP Scanjet G2410 Flatbed Scanner Drivers & Software for HP Scanjet G2410 Flatbed Scanner HP G2410 HP Scanjet Full Feature Software and Driver This download contains the required software/driver to scan pictures, documents and film as well as HP Photosmart software to manage, edit and share images.

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.

Mike BMike B
27.1k10 gold badges75 silver badges103 bronze badges

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.

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 Demaio

Phpmydirectory Scriptures

Marco Demaio

Phpmydirectory Script

20.7k31 gold badges112 silver badges148 bronze badges
hanshans
Sliq
9,45221 gold badges85 silver badges133 bronze badges
BradBrad
Jordan Ryan MooreJordan Ryan Moore
6,4372 gold badges22 silver badges27 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.

AlexAlex
7,2395 gold badges26 silver badges68 bronze badges
Vignesh KMVignesh KM

Try this. Works on both windows or linux server.

Phpmydirectory Scripture

str_replace(','/',dirname(dirname(__FILE__)))

cestarcestar
collidoscopecollidoscope

Phpmydirectory Script Fonts

This is a function that I use. Created it once so I always have this functionality:

JohnJohn
Goodhope Kudakwashe DhliwayoGoodhope Kudakwashe Dhliwayo

Phpmydirectory Script Hook

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/.

Ap is fine when it works. Hp printer scanner software free download It tends to work for a while and then go 'bad' at which point i. Crashes upon opening.

Tatu UlmanenTatu Ulmanen
101k28 gold badges165 silver badges178 bronze badges

Not the answer you're looking for? Browse other questions tagged phpdirectory or ask your own question.