I created a php class and it works fine with the php require for one of my pages that uses the class only when i have the shop.php in the same directory as the page: require("shop.php") Code (markup): but the problem is that I want to link to the shop class so multiple pages have direct access to it so i can update the file easily instead of putting the file in five different directories, but when I do the page does not work and I get an error. require("http://www.mysite.com/shop.php"); Code (markup): Why wont the php class work when I just give the page a path to it instead of having it in the same directory??
require requires absolute path, so you need to do something like: require('/user/home/dir/shop.php'); Contact your host for the absolute path to your home directory. Peace,
In most instances you cannot include/require files across domains. This is typically restricted (in php.ini) as a security measure. What you need to do is include the file relative to its location. Similar to what you have, minus the URL. So . . . require('includes/included_file.php'); Code (markup): Would include 'included_file.php' in the includes directory in the current working directory. require('../../includes/included_file.php'); Code (markup): Would be an included file (included_file.php) up two directories in the 'includes' directory.