码迷,mamicode.com
首页 > 其他好文 > 详细

文件包含include和require区别

时间:2019-06-04 09:26:39      阅读:108      评论:0      收藏:0      [点我收藏+]

标签:验证码   输入验证码   and   htm   html   int   随机   nbsp   Once   

文件加载原理:

  1.文件加载(include或require)的时候,系统会自动的将包含文件中的代码嵌入到当前文件中

  2.加载位置:在哪加载?对应的文件中的代码嵌入的位置就是对应的include位置 ,当前位置(跟html img 图片的路径差不多)。

  

    <?php
       include ‘./wen/index.php‘;
        echo $str;   //当前代码中没有$str    include  引用后可以使用
    ?>






<?php
// mt_rand(int $min,int $max) 产生随机数函数  $min ,$max   
$str="请输入验证码:";
$str.=‘<span style="color:rgb(‘.mt_rand(0,255).‘,‘.mt_rand(0,255).‘,‘.mt_rand(0,255).‘)">‘.mt_rand(0,9).‘</span>‘;   //产不不同颜色的验证码
$str.=‘<span style="color:rgb(‘.mt_rand(0,255).‘,‘.mt_rand(0,255).‘,‘.mt_rand(0,255).‘)">‘.mt_rand(0,9).‘</span>‘; 
$str.=‘<span style="color:rgb(‘.mt_rand(0,255).‘,‘.mt_rand(0,255).‘,‘.mt_rand(0,255).‘)">‘.mt_rand(0,9).‘</span>‘; 
$str.=‘<span style="color:rgb(‘.mt_rand(0,255).‘,‘.mt_rand(0,255).‘,‘.mt_rand(0,255).‘)">‘.mt_rand(0,9).‘</span>‘;   
?>

  

  include和include_once的区别:

  inclide:系统会碰到一次,执行一次,:如果对同一个文件进行多次加载,那么系统会执行多次;

  include_once:系统碰到多次,也会执行一次。

  require和reequire_once的区别:

        本质都是包含文件,唯一的区别在于包含不到文件的时候,报错的形式不一样。

  include :比较轻

  require:要求高,如果出错代码将不在执行。

 

 

 

 

 

 

 

        

  

  

 

 

 

 

 

 

 

 

 

 

  

文件包含include和require区别

标签:验证码   输入验证码   and   htm   html   int   随机   nbsp   Once   

原文地址:https://www.cnblogs.com/xiaowie/p/10971386.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!