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 711687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:45:48+00:00 2026-05-14T04:45:48+00:00

I want to find a method to include some files based on the current

  • 0

I want to find a method to include some files based on the current file path.. for example:

I have “website.com/templates/name1/index.php”, this “index.php should be a unique file that I will use in many different directories on different depths, so I want to make the code universal so I don’t need to change anything inside this file..

So if this “index.php” is located in

“website.com/templates/name1/index.php”

than it should include the file located here:

“website.com/content/templates/name1/content.php”

another example:

“website.com/templates/name2/index.php”

than it should include the file located here:

“website.com/content/templates/name2/content.php”

Also I want to overrun “Warning: include_once() [function.include-once]: http:// wrapper is disabled in the server configuration by allow_url_include=0” kind of error.. because is disabled and unsafe..

Is there a way to achieve this?
Thank you!

  • 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-14T04:45:49+00:00Added an answer on May 14, 2026 at 4:45 am

    I think you need to use __FILE__ (it has two underscores at the start and at the end of the name) and DIRECTORY_SEPARATOR constants for working with files based on the current file path.

    For example:

    <?php
      // in this var you will get the absolute file path of the current file
      $current_file_path = dirname(__FILE__);
      // with the next line we will include the 'somefile.php'
      // which based in the upper directory to the current path
      include(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'somefile.php');
    

    Using DIRECTORY_SEPARATOR constant is more safe than using “/” (or “\”) symbols, because Windows and *nix directory separators are different and your interpretator will use proper value on the different platforms.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to find records on a combination of created_on >= some date AND
I want to find any text in a file that matches a regexp of
i want to find the mime-type for a given file extension on an IIS
I am writing a system monitor for Linux and want to include some watchdog
I have a Django application being served of (say) example.com . It contains a
I want to find a way to develop database projects quickly in Visual Studio.
I want to find out all the subdomains of a given domain. I found
I want to find a sql command or something that can do this where
I want to find an SQL query to find rows where field1 does not
I want to find a linux command that can return a part of the

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.