Reputation: 11
I am trying to include my header,footer and sidebar files like this,
include($str_url.'header.php');
include($str_url.'sidebar.php');
include($str_url.'footer.php');
i have defined $str_url = "http://www.example.com/";
in my constant file,
But is not working in my server. how can i fix it?
Please help me.
Thanks.
Upvotes: 0
Views: 130
Reputation: 2537
You most probably don't want to include
URLs into your main php file, but the local .php-files. include ('/path/to/a.php');
instead of include ('http://url/to/a.php');
(source: http://php.net/manual/en/function.include.php)
Upvotes: 5
Reputation: 129
You should never include files via an absolut URL, because you will not be including the actual code, but the result of it. Instead use relative paths or server paths (/home/user/public_html) Easiest way would be via relative paths. For example, if you have index.php and header.php in the same folder, you can just use: include('header.php'); If the files, are in another folder, for example you have header.php in an 'includes' folder, than you would use in your index.php: include('includes/header.php');
Upvotes: 1
Reputation: 1106
You probably need modify php.ini allow_url_include = On.
But better never include files via http.
Upvotes: 2