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

 

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.