Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6341835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:07:06+00:00 2026-05-24T20:07:06+00:00

I have a new project that has a bit of code at the beginning

  • 0

I have a new project that has a bit of code at the beginning of every page. I am in need of some clarification on what this series of statements do. Here is the opening call:

<?php
session_start();
$levels = 1;
include("../Connections/main.php");
include("../queries.php");

I understand all of it except how $levels = 1; relates to include("../queries.php");

When I look at include("../queries.php"); I see that it begins with the following statement:

<?php
switch($levels) {
case 1:
$dir = "../";
break;

case 2:
$dir = "../../";
break;


case 3:
$dir = "../../../";
break;

case 4:
$dir = "../../../../";
break;

case 5:
$dir = "../../../../../";
break;
}
function db_info($table,$where,$value,$info,$dir) {
//the functions just continue from there

This is the portion that I don’t follow. I understand that there is a switch statement that offers several cases for $dir based upon the value of $levels which was defined in the first bit of code. But how do these different outputs for the $dir value translate? Is this something you’ve seen or used before? What does the ../ stand for? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T20:07:09+00:00Added an answer on May 24, 2026 at 8:07 pm

    This is a ../ always refers to parent directory, the more ../ the more parents you get. With enough you can get to the root of the file system (though you’re better off just using /). This isn’t exactly the best way to accomplish this.

    $dir = str_repeat( '../', $level );
    

    Would be more obvious and it would be more extensible. A better option still would be to have some config file which simply did something like:

    // obviously this would be a better constant name.
    define( 'PATH_TO_STUFF', dirname( __FILE__ ) ); // use __DIR__ on PHP 5.>=3
    

    Bonus info:

    • ./ = current directory
    • ../ = parent directory
    • ./../../ = grandparent of current directory
    • ./../../foo/../ The parent directory of the folder foo in the grandparent directory (ie. the grandparent directory). (I am your father’s, brother’s, nephew’s, cousin’s former roommate)
    • / = file system root directory.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Question So I've recently came up with some new possible projects that would have
I am fairly new to MySQL and have a project in which I need
I have a bit of .NET code that retrieves the results from an Oracle
We have a project that has two one to many relationships. We encounter a
I have been given new project which has many classes and I have to
I have a school project and i want to dedicate this for New Year,
I currently have a Rails website that has some Prototype scripting in it. My
I have a java application build upon Spring 3. This project has another jar
I have a new project which simply put, is an attempt to formalize the
My new project is targeting an embedded ARM processor. I have a build system

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.