开发者

URL file access in php

开发者 https://www.devze.com 2023-03-23 10:49 出处:网络
I am trying to include my header,footer and sidebar files like this, include($str_url.\'header.php\');

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.


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)


You probably need modify php.ini allow_url_include = On.

But better never include files via http.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号