Jump to content

I'm tired and missing somethings or my sever is messed up?


Rifts

Recommended Posts

Hey everyone this is really really simple.

 

say my site is www.mywebsite.com

 

in my index page I have this

define('PHPSITE_DIR', 'mywebsite');

require_once(PHPSITE_DIR . '/test/hello.php');

 

I have a folder named test and inside the folder i have hello.php

 

but when i go to www.mywebsite.com

 

i get

Warning: require_once(mywebsite/test/hello.php) [function.require-once]: failed to open stream: No such file or directory in

 

wtf?

 

i'm using godaddy server if that matters

 

 

Link to comment
Share on other sites

require/include expects a correct file system path. You can either use an absolute file system path, a relative path (relative to the main page that was requested), or you can make use of the include_path and let php search for the file.

 

An absolute file system path would typically use $_SERVER['DOCUMENT_ROOT'] to get the absolute path of your document_root folder, then append the path and file name of the file you want to require/include.

 

A relative path starts with either a leading .. or ., such as ../some_folder/some_file.php

 

Using the include_path, you just list the bare file name, such as require('some_file.php') and php will search in the include_path to find the file. The include_path setting typically has a dot . as the first entry so that the current folder will be searched first.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.