Home > Backend Development > PHP Tutorial > 求教一个include_once路径问题

求教一个include_once路径问题

WBOY
Release: 2016-06-23 13:52:58
Original
1673 people have browsed it

文件里面2个文件:
a.php
b.php

b页面内容:
1. include_once(dirname(__FILE__).'/a.php');
2. include_once('./a.php');
3. include_once(a.php');
该用哪种方式调用呢?


回复讨论(解决方案)

最简洁的是 3,当然需要 include_path 中有 . 这一项
1 最严密,也最麻烦最低效

3种都可以,但第一种如果出错最容易发现问题。

三种效果一样,这有什么纠结的?

还可以用完整路径  include_once '/var/www/html/a.php';  这样不用为多文件嵌套路径报错而烦恼了

还可以用完整路径  include_once '/var/www/html/a.php';  这样不用为多文件嵌套路径报错而烦恼了

还可以用完整路径  include_once '/var/www/html/a.php';  这样不用为多文件嵌套路径报错而烦恼了

3. include_once(a.php');  

显然写错了.... 

include_once('a.php');

更多时候我会写成

1 OR 2  这个看个人的习惯吧.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template