answersLogoWhite

0


Best Answer

You can use the double-period-slash (../) to signify a link to a parent directory (for a relative path) or trim the contents of the current script's path (found in the magic constant "__FILE__" and the superglobal array key "$_SERVER['PHP_SELF']") with a function like explode and implode to find the directory above it (for an absolute path).

For the latter, here is an example:





// Get the current script path
$path = $_SERVER['PHP_SELF']; // "/example/path/index.php"
// Divide up the path (into an array) by its forward-slashes
$path = explode('/', $path);
// Remove the last two array keys to get the parent directory
unset($path[count($path)]); // Removes last key
unset($path[count($path) - 1]); // Removes second-to-last key
// Put the path pieces back together with a slash between each piece (to form the path) // Also, add a forward-slash to make it appear as a directory
$path = implode('/', $path) . '/';
// Use the new path as desired!
echo $path; // "/example/"
?>

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How can you link to a file found in a parent directory without the use of the double-period-slash in PHP?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Where is the FSX directory?

A flight simulator game upload told me that my FSX directory was corrupted. How can I fix it? Where is the directory found?


How many medical clusters are found in the directory?

there are 20 medical clusters in the directory


What main group type is found in Active Directory?

The main group type found in active directory is the security group.


Is there a directory of email addresses?

Not that I have found.....


Is aportstorage found in Google Directory?

I have seen aportstorage many times in directory of Google


Where is directory advertising to be found?

There are many different types of directory advertising, depending on where you are from in the World. The best way to find the right directory advertising is by searching for your locality.


What services are provided by Directory Submission?

Directory submission allows people to submit their product or service to a directory so that it can be found more quickly by their potential customers.


What is a directory computer science?

A directory is a location for storing files on your computer. Directories are found in a hierarchical file system such asDOS, OS/2, Unix, etc. When referring to a directory, a user commonly indicates the name of the directory.


Where can one find a directory of Columbia attorneys?

A directory of Columbia attorneys can be found on the Columbia Attorney website. This directory offers an extensive list of attorneys for any type of individual.


What is a directory in the sense of a computer files?

Directories and folders are interchangeable terms. In the days before Windows (known as the "DOS" days), "Folders" were called, "Directories." To explain what a directory was, it was said to be "like a folder" which held documents (files) and sometimes envelopes (sub-directories) which could also hold other envelops and/or documents etc. etc. At some point Microsoft started referring to "Directories" as "Folders" supposedly to make it easier to understand for those new to computers. Computer files are always found in a named Directory. If a file isn't in a named directory, it is said to be in the "Root" directory i.e "In the root directory of the D: drive." Further, if a sub-directory/folder is in another directory, it is the "child" of the "parent" directory.


When the parent have joint custody and the child gets taken by social services who gets the child if one parent is found unfit?

Generally, if one parent is found to be unfit the other parent will have sole legal and physical custody. Courts favor the biological parent in regards to custody.Generally, if one parent is found to be unfit the other parent will have sole legal and physical custody. Courts favor the biological parent in regards to custody.Generally, if one parent is found to be unfit the other parent will have sole legal and physical custody. Courts favor the biological parent in regards to custody.Generally, if one parent is found to be unfit the other parent will have sole legal and physical custody. Courts favor the biological parent in regards to custody.


What kind of account is not found in Active Directory?

local user account