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

  • SEARCH
  • Home
  • 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 6211103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:16:45+00:00 2026-05-24T06:16:45+00:00

I am developing a php MVC framework from scratch and have run into an

  • 0

I am developing a php MVC framework from scratch and have run into an interesting problem with the relative pathing of a default WAMP deployment… the problem arose when I was beginning to write includes and requires from within the framework…

My framework entry point lives one folder deep in the document root:

http://localhost/platform/index.php <- framework entry point; the physical path being c:/wamp/www/platform/

When I run the following directory traversal code from ANY file in the framework…

$handle = opendir('./');
while ($file = readdir($handle))
{    
    echo $file."<br/>";   
}

…I get the SAME RESULT:

.
..
ABOUT_APACHE.txt
bin
cgi-bin
CHANGES.txt
conf
error
htdocs
icons
include
INSTALL.txt
lib
LICENSE.txt
logs
manual
modules
NOTICE.txt
OPENSSL-NEWS.txt
OPENSSL-README.txt
README-win32.txt
README.txt
wampserver.conf

That is the contents of the folder at c:/wamp/bin/Apache2.2.17/

dumping the ini_get(‘include_path’) “.;c:/php/pear” …This is curious because it’s the default WAMP install, which puts php at c:/wamp/bin/php/php5.3.4/, and as far as I can tell, doesn’t put PEAR anywhere (I don’t see it in the php5.3.4 folder!)…

First question: Why isn’t “./” from within any particular file in the webroot referring to the directory in which the file from which it is called sits? First question, second part: why is it always referring to the root of the wamp-deployed apache folder, regardless of calling file’s location?

Dumping the contents of the folder at “/” reveals:

$INPLACE.~TR
$RECYCLE.BIN
$WINDOWS.~Q
boot
bootmgr
BOOTSECT.BAK
cert.pfx
Config.Msi
Documents and Settings
DVDPATH.TXT
hiberfil.sys
HP
msdia80.dll
MSOCache
pagefile.sys
PerfLogs
Program Files
Program Files (x86)
ProgramData
Recovery
SWSetup
System Volume Information
System.sav
updatedatfix.log
Users
wamp
Windows

Second Question – why does the path “/” when opened from my script refer to C:\ and not the document root (which would be C:\wamp\www)

Last Question – How do I configure PHP to ensure that what I BELIEVE is the expected pathing in those situations (/ => document root, ./ => folder of the referencing script) actually IS the path for those references?

Am I totally doing this wrong? At one time I thought that the relative pathing was in reference to the CALLED script, or the entry point’s folder, c:/wamp/www/platform/ in this case… Regardless of what file is making the reference, but php.net documentation seems to say otherwise. PHP.net says that whatever folder the FILE is in that is executing the function using a relative path (with leading period) should be the starting location of the relative path. Neither seems to be the case in my configuration…

Thanks for your time!

  • 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-24T06:16:46+00:00Added an answer on May 24, 2026 at 6:16 am

    First question: Relative include paths are interpreted relative to the current working directory; when run through apache + mod_php, this is usually the location of the top-level script that gets called directly from apache. This is a somewhat unfortunate design decision which, due to PHP’s popularity, cannot be undone.

    Second question: PHP was originally written for Unix-like systems, where / indicates the absolute filesystem root. Windows does not have such a thing, so instead, PHP uses the next best thing, the top-level directory on the principal filesystem, which is usually C:\.

    Third question: Two solutions here. First solution: set up a proper include_path in your auto-prepend script, and use only relative names, e.g. when you have C:\www\myproject\foo\bar.php, add C:\www\myproject\foo to your include_path, and just include 'foo.php'. Second solution: use a combination of the dirname() function and the __FILE__ superglobal to make your includes explicitly relative to the current file, e.g. when you want to include C:\www\myproject\foo\bar.php from C:\www\myproject\baz.php, use something like include dirname(__FILE__) . '/foo/bar.php'. In practice, you will probably use a combination of both methods, i.e., use the dirname(__FILE__) trick in the auto-prepend script to set the include path relative to the auto-prepend script itself.

    If you use PHP’s OOP features, you will also want to set up a class autoloader, so that you don’t have to explicitly include the definitions of all the classes you use.

    Oh, and you probably want to read up on the documentation: http://www.php.net/manual/en/function.include.php

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

Sidebar

Related Questions

I'm developing an MVC framework in PHP from scratch; mostly for the learning experience
I'm developing MVC engine for real estate web-site from scratch. Currently I have this
Im currently developing a MVC application Framework and I have come for some advise
So I am just starting out developing PHP web applications and have finished setting
I'm using NetBeans 6.5 for developing PHP and I have xdebug setup. Is there
I'm developing a website in PHP and I have large JS files that I
i am developing a php application which run on offline mode mean not connect
I have a personnel database of 10,000 individuals. I am developing a PHP CMS
I have been asked to build a PHP application that inserts data into a
I am developing a MVC application with PHP that uses XML and XSLT to

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.