0

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.

4
  • 4
    Never include remote files (and as a sidenote: $$str_url is obviously not a constant. Use constants instead define()) Commented Jul 27, 2011 at 12:23
  • -1. use search. Commented Jul 27, 2011 at 12:25
  • probably your answer here Commented Jul 27, 2011 at 12:25
  • I'm assuming the "example.com" is actually set to your sites url? is that correct? Commented Jul 27, 2011 at 12:26

3 Answers 3

5

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)

Sign up to request clarification or add additional context in comments.

Comments

2

You probably need modify php.ini allow_url_include = On.

But better never include files via http.

Comments

1

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');

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.