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

求教一个include_once路径有关问题

WBOY
Release: 2016-06-13 12:03:27
Original
959 people have browsed it

求教一个include_once路径问题
文件里面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';  这样不用为多文件嵌套路径报错而烦恼了

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