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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:19:44+00:00 2026-05-25T14:19:44+00:00

Here is my directory listing : >htdocs –>MyWeb —->admin ——>cms.php —->images —->controller ——>post.php ——>general.php

  • 0

Here is my directory listing :

>htdocs
-->MyWeb
---->admin
------>cms.php
---->images
---->controller
------>post.php
------>general.php
---->model
------>posts.php
------>sessions.php
------>connections.php
---->index.php

and here are the includes for each page starting from top :

cms.php:
    require_once('../model/sessions.php');
    require_once('../controller/post.php');
post.php:
    require_once('general.php');
    require_once('../model/posts.php');
general.php : none 
posts.php:
    require_once('sessions.php');
    require_once('connections.php');
sessions.php:
    require_once('connections.php');
connections.php : none
index.php:
    require_once('controller/post.php');

condition : tested everything fine with cms.php, i got access to all the function using forms provided by the controller, and the controller got the data from model.
now, the administration things are done, time to get to the index.php to show the data, i put inside index.php, when i open it, here’s what happened :

I got errors which tell me that the “require_once()” function cannot locate the specified file. I did this with cms.php and its all right. The errors are not from index.php, but from
the file included within it (post.php).

lets take a look again in index.php, it has included the controller, post.php using “require_once(‘controller/post.php’) ;”, but the post controller itself, includes another file,
which is the post model “require_once(‘../model/posts.php’)”. The problem occurs when index.php view the required file of the controller using top folder perspective (MyWeb), then reads the file included
in post controller as exactly “require_once(‘../model/posts.php’)” = up one folder of index.php, folder model, which mean :

htdocs>model>posts.php which is of course, didn’t exist. I was really confused at the first time, then i create some cheats for this :

1. I put a variable $check = true ; before the require_once('controller/post.php') ; in index.php
2. then for each page that requires another file, i put these :
    //for example, in sessions.php
    if(isset($check)) {
        //old link which is like this : require_once('connections.php') ; has become :
        require_once('model/connections.php') ;
        //so in index.php perspective, the file can be reached
    }
    else {
        //old links, only executed when this page was not viewed from index.php
        require_once('connections.php') ;
    }
3. it works now, cms.php read the includes from old links, while index.php will read the included from new links.

Now, even though it works, my codes look ugly and inconsistent if in the future, i might add more files, more includes.
question : do anyone has better solution for this ? how to access working directories of the application, such in linux using : ~/controller/post.php or ~/model/posts.php. so the address will be consistent.
can’t use getcwd(), i dont want to show the absolute path of my files. does anyone can give me better solution for specifying directories such in my case ?

note : pardon my english

  • 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-25T14:19:44+00:00Added an answer on May 25, 2026 at 2:19 pm

    how to access working directories of the application, such in linux using : ~/controller/post.php or ~/model/posts.php.

    $_SERVER['DOCUMENT_ROOT']
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

here is my directory structure. /user/a /user/b /user/b inside folder a,b,c there is a
Here is the directory layout that was installed with Leopard. What is the A
Here's the scenario: I run compc on a source directory to recompile an already
Here's an example: >git status # On branch master nothing to commit (working directory
If doing a directory listing and reading the files within, at what point does
Quick question. I have a listbox being populated from a directory listing. Each file
In another question - Getting directory listing from SVN for use in ANT dropdown
I'm struggling with a strange file name encoding issue when listing directory contents in
I'm revamping my work's Employee Directory, adding hCard data to each employee's listing. An
I have a directory of 9 images: image_0001, image_0002, image_0003 image_0010, image_0011 image_0011-1, image_0011-2,

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.