1.include语句

使用include语句可以告诉PHP提取特定的文件,并载入它的全部内容
  1.  <?php
    inlude "fileinfo.php"; //此处添加其他代码
    ?>
 
 
2.include_once语句
 
每次使用include语句时,它都会重新将请求的文件导入,即使这个文件已经被导入过。例如,假定fileinfo.php文件包含许多函数,我们使用include语句将他导入到现有的文件中,然后我们又导入了一个包含fileinfo.php的文件,通过嵌套,我们已经将fileinfo.php文件导入了两次,这就会产生错误,因为我们试图多次定义同名的变量或函数。为了避免这样的事情发生,我们使用include_once语句来代替include语句
  1.  <?php
    include_once "fileinfo.php"; //此处添加其他代码
    ?>
此时,如果在相同的文件中遇到另一个include或include_once语句时,PHP会检查它是否已经被导入过,如果是,就忽略它。
 
 
3.require和require_once语句
 
使用include和include_once语句的潜在问题是:PHP只会试图导入被请求导入的文件,即使该文件没有被找到,程序依旧会执行。
当我们绝对需要导入一个文件时,使用require语句,对于使用require_once语句的原因也是一样的,在这就不再赘述了。
  1.  <?php
    require_once "fileinfo.php"; //此处添加其他代码
    ?>
 
总的来说,我们应该坚持使用require_once语句。
 
 

:first-child { margin-top: 0; } blockquote > :last-child { margin-bottom: 0; } img { border: 0; max-width: 100%; height: auto !important; margin: 2px 0; } table { border-collapse: collapse; border: 1px solid #bbbbbb; } td { padding: 4px 8px; border-collapse: collapse; border: 1px solid #bbbbbb; } @media screen and (max-width: 660px) { body { padding: 20px 18px; padding: 1.33rem 1.2rem; } } @media only screen and (-webkit-max-device-width: 1024px), only screen and (-o-max-device-width: 1024px), only screen and (max-device-width: 1024px), only screen and (-webkit-min-device-pixel-ratio: 3), only screen and (-o-min-device-pixel-ratio: 3), only screen and (min-device-pixel-ratio: 3) { html, body { font-size: 17px; } body { line-height: 1.7; padding: 0.75rem 0.9375rem; color: #353c47; } h1 { font-size: 2.125rem; } h2 { font-size: 1.875rem; } h3 { font-size: 1.625rem; } h4 { font-size: 1.375rem; } h5 { font-size: 1.125rem; } h6 { color: inherit; } ul, ol { padding-left: 2.5rem; } blockquote { padding: 0 0.9375rem; } }
-->
:first-child { margin-top: 0;}blockquote > :last-child { margin-bottom: 0;}img { border: 0; max-width: 100%; height: auto !important; margin: 2px 0;}table { border-collapse: collapse; border: 1px solid #bbbbbb;}td { padding:4px 8px; border-collapse: collapse; border: 1px solid #bbbbbb;}@media screen and (max-width: 660px) { body { padding: 20px 18px; padding: 1.33rem 1.2rem; }}@media only screen and (-webkit-max-device-width: 1024px), only screen and (-o-max-device-width: 1024px), only screen and (max-device-width: 1024px), only screen and (-webkit-min-device-pixel-ratio: 3), only screen and (-o-min-device-pixel-ratio: 3), only screen and (min-device-pixel-ratio: 3) { html, body { font-size: 17px; } body { line-height: 1.7; padding: 0.75rem 0.9375rem; color: #353c47; } h1 { font-size: 2.125rem; } h2 { font-size: 1.875rem; } h3 { font-size: 1.625rem; } h4 { font-size: 1.375rem; } h5 { font-size: 1.125rem; } h6 { color: inherit; } ul, ol { padding-left: 2.5rem; } blockquote { padding: 0 0.9375rem; }}
-->

PHP中的include和require的更多相关文章

  1. php 中使用include、require、include_once、require_once的区别

    在PHP中,我们经常会通过include.require.include_once.require_once来引用文件,都可以达到引用文件的目的,但他们之间又有哪些区别呢,接一下我们详细的介绍一下 i ...

  2. 彻底搞明白PHP中的include和require

    在PHP中,有两种包含外部文件的方式,分别是include和require.他们之间有什么不同呢? 如果文件不存在或发生了错误,require产生E_COMPILE_ERROR级别的错误,程序停止运行 ...

  3. php中include()和require()的区别

    1.引用文件方式 对 include()来说,在include()执行时文件每次都要进行读取和评估:而对于require()来说,文件只处理一次(实际上,文件内容替换 了require()语句.这就意 ...

  4. php include 与 require 起底[转]

    转自 http://www.guangla.com/post/2014-01-24/40060857811 起因: 一朋友面试被问到,php的include和require的区别,这个可能是面试中出现 ...

  5. include 和require 区别

    include和require的区别  1.include() 包含文件 2.include_once(filename)如果已经包含,则不再执行include_once 3.requirerequi ...

  6. PHP中include()与require()的区别说明

    require 的使用方法如 require("MyRequireFile.php"); .这个函数通常放在 PHP 程序的最前面,PHP 程序在执行前,就会先读入 require ...

  7. PHP中include()与require()

    引用文件的方法有两种:require 及 include. require 的使用方法如 require("file.php"); .这个函数通常放在 PHP 程序的最前面,PHP ...

  8. PHP中include和require的区别详解

    1.概要 require()语句的性能与include()相类似,都是包括并运行指定文件.不同之处在于:对include()语句来说,在执行文件时每次都要进行读取和评估:而对于require()来说, ...

  9. PHP中include和require(转)

    昨天去面试一个php开发,看到笔试试卷上有这么一道题目: include和require有什么区别? 这个题目可以称得上php开发面试中的必考题目,网上也有各种答案和解释.但是我当时却真的想不起来了. ...

随机推荐

  1. 【Java Saves!】Session 6:十六指星人

    前面说,计算机用2个手指头数数,它内部的数是二进制,有0和1两个数字.也看到,对于人来说,二进制数too long, too inconvenient, sometimes troublesome.程 ...

  2. trie树---(插入、删除、查询字符串)

    HDU   5687 Problem Description 度熊手上有一本神奇的字典,你可以在它里面做如下三个操作:  1.insert : 往神奇字典中插入一个单词  2.delete: 在神奇字 ...

  3. UVA 10090 - Marbles 拓展欧几里得

    I have some (say, n) marbles (small glass balls) and I am going to buy some boxes to store them. The ...

  4. [moka同学笔记]yii2.0数据库操作以及分页

    1.model中models/article.php 1 <?php 2 3 namespace app\models; 4 5 use Yii; 6 7 /** 8 * This is the ...

  5. Ahjesus获取自定义属性Attribute或属性的名称

    1:设置自己的自定义属性 public class NameAttribute:Attribute { private string _description; public NameAttribut ...

  6. java File.mkdirs和mkdir区别

    File f = new File("e://xxx//yyy"); System.out.println(f.mkdirs());//生成所有目录,一般来说,这个方法稳健性更好, ...

  7. 胖AP(1602i)与苹果设备之间的问题总结

    问题现象: 苹果设备(5GHz)连接不稳定,表现为时断时续,或者加入无线的时候一直加入不进去. 有些2.4GHz设备会在几个AP之间相互跳. 分析: 1. 先说苹果设备,它既支持2.4G 也支持5G, ...

  8. 初学Node(四)事件循环

    Node中的事件循环 事件循环是Node的核心,正是因为有了事件循环JS才能够在服务端占有一席之地.JS是一种单线程语言,但是它的执行环境是多线程的在加上JS的事件驱动这一特点,使使JS在执行的过程中 ...

  9. miniSipServer简单而不简单,轻松落地,实现电脑对固话、手机通讯

    最近沉迷于SIP通讯,网内通讯全免费,落地也就几分钱,而且无漫游全国拨打,想想真是心动呢,只要有网落就ok!. 对于sipserver,现在的市场上软件很多,免费的.收费的应有尽有,这里不一一例举.综 ...

  10. Git使用ssh key

    生成ssh key步骤 这里以配置github的ssh key为例: 1. 配置git用户名和邮箱 git config user.name "用户名" git config us ...