Arslan Khan
Arslan Khan

Reputation: 95

How to Reference File Two Directories Up, in Current File in PHP

  1. List item

I have a dircetory Security in which there is a file index.html and another folder security which contains docs folder and in docs folder there is file banner.html. I want to add banner.html through in index.html but I am not being able to understand which pathe to use.

Security-> index.html and security folder-> docs-> banner.html. I want to add banner.html in index.html. Please any Idea? I shall be very thankful for any help.

My directory and file structure is

Root folder is Security with capital S and inside it are index and security with small s and security contains Docs and Docs contains banner.html and I want to add banner.html in index.html

Upvotes: 0

Views: 146

Answers (1)

Tom Dickson
Tom Dickson

Reputation: 622

I see that all your files are HTML however you have added the PHP tag to your comment, so my solution will be written PHP. So if I am understanding correctly you folder structure follows:

  • Security
    • Index.php
    • security
      • Docs
        • Banner.php

So in your index.php file you can place

<?php require __DIR__ . 'security/Docs/banner.php'; ?>

or

<?php include __DIR__ . 'security/Docs/banner.php'; ?>

Read more about Require, Include and DIR

Upvotes: 1

Related Questions