PHP路径包含文件(PHP Path to Include Files)

   IT问题网   2019-08-16 00:00:00

问 题

我有一个网站用的index.php。 在index.php拥有一批包括像文件

  php include_once('脚本/ php / index_mainimagejoin.php');?
 

我创建了一个新的文件夹断称为"extrapages"的根源,我将有一个有关于该网站的信息在里面的页面。我已经添加了include_once文件,如上面和更改路径和这些挂钩的罚款。

我发现这个问题是路径中包含文件失败。例如:如果一个图像或其他包含文件中包含它从"extrapages"文件夹中运行时出现故障。路径问题。

有没有好的办法来处理这个? 我可以改变一个偶然的机会/路径设置站点根目录(www)的页面下的"extrapages"到一个文件夹下?

我可以将这些网页上的根源,他们会运行得很好,但我真的不希望在站点的根目录所有的混乱。

任何想法和放大器; thx

解决方案

的关键,任何路径问题被称作绝对路径

  • 在创建的链接的为您的网站(包括图像源),总是从 / 启动其次是完全正确的路径。它永远不会让你失望。

  • 同为文件系统调用:总是使用绝对路径。你的服务器通常为您提供了一个名为 $ _ server ['document_root'] 包含的地步,文件系统满足web服务器非常方便的变量,指向你的网站根目录。

所以,从任何地方在您的网站调用的时候,

 包括$ _ server ['document_root']'/脚本/ php / index_mainimagejoin.php"。
 

总是指向同一位置

标签:路径包含包括包孕蕴含文件



分享:

  • 微信
  • QQ好友
  • QQ空间
  • 新浪微博


热门推荐

重写URL隐藏的index.php并作出查询不错(Rewriting url to hide index.php and to make query nice)

problem i had developed project with custom mvc architect ...

htaccess的URL路由的PHP MVC?(htaccess URL routing for PHP MVC)

problem i've been searching and have yet to find an artic ...

的.htaccess规则相应的HTTP链接,HTTP和HTTPS重定向到HTTPS?(.Htaccess rules to redirect respective HTTP links to HTTP and HTTPS to HTTPS)

problem first, here's the .htaccess rule i cu ...

使用的.htaccess追加html的URL路径的背后(using .htaccess to append .html behind url path)

problem people are coming into my website like this: sit ...

的.htaccess迫使对SSL错误页面(.htaccess forcing error pages on SSL)

problem i have the following piece of code in ...

可变301重定向URL(301 redirect URL with variable)

problem i want to use htaccess to 301 redirect (not rewri ...

htaccess的重定向example.com/index.php到example.com/home~~V(htaccess redirect example.com/index.php to example.com/home)

problem thanks in advance, i am trying to redirect anyone ...

htaccess的重写规则问题(.htaccess Rewrite Rule Problems)

problem can anyone help me with htaccess rewr ...

htaccess的子域名与所有的变量文件参数(.htaccess sub domain as file parameter with all the variables)

problem i want to make this url redirect usin ...

字preSS定制的mod_rewrite - totalnoob?(Wordpress custom mod_rewrite - totalnoob)

problem i'm trying to make a custom mod_rewrite rule for ...

我怎样才能让我的网址,从这个例子中友好吗?(How can I make my urls friendly from this example)

problem my site currently displays like this (when clicki ...

htaccess的问题强制SSL(.htaccess issue to force SSL)

problem i activated ssl on one of my sites (based on word ...

IfModule不会出现是工作?(IfModule doesn't appear to be working)

problem if i use this: lt;ifmodule mod_rewrite.cgt; rewr ...

我怎样才能利用外界信息的URL重写?(How can I get use outside information in url rewrites)

problem hopefully some of you .htaccess gurus can help me ...

基于URL到一个新的页面的RewriteCond重写规则进行的.htaccess,定期EX pression(RewriteCond RewriteRule for .htaccess based on URL to a new page, regular expression)

problem i have an interesting rewriterule and i am not su ...

的.htaccess,mod_rewrite的,正则表达式用目录和文件类型(.htaccess, mod_rewrite, regex with directory and filetype)

problem i want to do a rewrite with the following conditi ...

.htaccess的语言重定向310错误(Htaccess language Redirect 310 error)

problem i have a two language site swedish sidewww.site ...

重定向一切的index.php(Redirection everything to index.php)

problem i wan't to redirect everything to index.php exepe ...

生成SE友好的URL的.htaccess国防部重写(Generating SE friendly URL .htaccess mod rewrite)

problem i've a url which get file name through get method ...

htaccess的子域名重定向(htaccess subdomain redirect)

problem i've searched around and tried a few ...