`
xumingrencai
  • 浏览: 1180172 次
文章分类
社区版块
存档分类
最新评论

__FILE__ 与 $_SERVER['SCRIPT_FILENAME']的区别

 
阅读更多

二者都表明了本文件的绝对路径,区别在于,
$_SERVER['SCRIPT_FILENAME']指向当前执行脚本的绝对路径;
__FILE__指向当前文件的绝对路径;也就是写在哪个文件里就是哪里。

例子:

  1. //test.php
  2. require'common/inc.php';
  1. //common/inc.php
  2. echo'SCRIPT_FILENAME为:'.$_SERVER['SCRIPT_FILENAME'];
  3. echo'<br/>';
  4. echo'__FILE__为:'.__FILE__;

执行test.php,显示结果为:

SCRIPT_FILENAME 为:D:/AppServ/www/test.php
__FILE__为:D:\AppServ\www\common\inc.php

分享到:
评论

相关推荐

    nginx 1.9 window 版本

    fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name; include /etc/nginx/fastcgi_params; } # 定义错误提示页面 error_page 500 502 503 504 /50x.html; location = /50x.html { root /...

    php中的路径问题与set_include_path使用介绍

    //输出D:\phpweb\php_example 2.$_SERVER[‘SCRIPT_FILENAME’]; //输出D:/phpweb/php_example/include_path.php second: php中的set_include_path 在php中,include文件时,当包含路径不为相对也不为绝对时(如:...

    数据库设计报告.pdf

    id FK1 Si_id Si_pollsum Si_E Si_D Si_C Si_B Si_A SWS_buckup PK Bu_id Bu_type Bu_file_station Bu_filename Bu_time Bu_sweek Bu_date SWS_reckoning PK Reck_id FK1 Of_id FK2 Si_id sI_software_name Sl_price...

    minecraft_script:这是一个简单的工具,用于自动向我的世界服务器发出命令

    filename: 'minecraft_server.jar', // file name of minecraft server opts: 'nogui', jvm: 'java', // jvm path start_cmd: '-Xmx3G -Xms512M -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalPacing -XX:...

    最全的oracle常用命令大全.txt

    select tablespace_name, file_id, file_name, round(bytes/(1024*1024),0) total_space from dba_data_files order by tablespace_name; 3、查看回滚段名称及大小 select segment_name, tablespace_name, r....

    php.ini-development

    Using this ini directive may cause problems unless you know what script ; is doing. ; Note: You cannot use both "mb_output_handler" with "ob_iconv_handler" ; and you cannot use both "ob_gzhandler" ...

    鲜花网站建设

    鲜花店&lt;SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT&gt; dim upfile_5xSoft_Stream Class upload_5xSoft dim Form,File,Version Private Sub Class_Initialize dim iStart,iFileNameStart,iFileNameEnd,iEnd,...

    ZendFramework中文文档

    4.3.5. Zend_Cache_Frontend_File 4.3.5.1. Introduction 4.3.5.2. Available options 4.3.5.3. Examples 4.3.6. Zend_Cache_Frontend_Page 4.3.6.1. Introduction 4.3.6.2. Available options (for this ...

    无组件ASP文件上传源代码

    file.SaveAs Server.mappath("updata\"&file.FileName) ''保存文件 end if set file=nothing next set upload=nothing response.write "文件上传成功 [ (-1)&gt;继续上传&lt;/a&gt; ]&lt;/font&gt;" %&gt; &lt;/body&gt; &lt;/html&gt; --...

    ASP化境无组件上传

    &lt;SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT&gt; dim Data_5xsoft Class upload_5xsoft dim objForm,objFile,Version Public function Form(strForm) strForm=lcase(strForm) if not objForm.exists(strForm) then ...

    ASP使用FSO读取模板的代码

    m_Root是文件名,可以使用相对路径。 调用调用示例: Response.Write...&gt;”” Then Filename = Filename & “/” Filename = Server.MapPath(Filename & m_FileName) Set fso = CreateObject(“Scripti

    asp连接数据库代码实例

    --#include file=\"Conn.asp\"--&gt; db=\"data/data.mdb\" \'数据库存放目录 on error resume next set conn=server.createobject(\"adodb.connection\") conn.open \"driver={microsoft access driver (*.mdb)}...

    asp.net 文件夸域名传输带进度条

    &lt;script type="text/C#" runat="server"&gt; BinaryReader ms; UploadInfo uploadInfo = null; protected void Page_Load(object sender, EventArgs args) { if (this.IsPostBack) { uploadInfo = this....

    FastReport.v4.15 for.Delphi.BCB.Full.Source企业版含ClientServer中文修正版支持D4-XE5

    FastReport.v4.15 for.Delphi.BCB.Full.Source企业版含ClientServer中文修正版支持Delphi 4-XE5 and C++Builder 6-XE5. D2010以上版本(D14_D19)安装必读 delphi2010以上版本(D14_D19)使用者安装时,请将res\frccD14_...

    crtmpserver源码

    * Replace file-download with the actual filename of your sample you download. Remeber to omit the .flv if it's an FLV file * Open a web browser and point it to to the web server IP/Hostname and the ...

    ELDK使用与开发手册

    Filename ””/tftpboot/uboot.bin””. Load address: 0×100000 Loading: ############################### done Bytes transferred = 155376 (25ef0 hex) =&gt; protect off 40000000 4003FFFF Un-Protected 5 ...

    Ajax in action 英文版配书源码.rar

    Dear 'Ajax in Action' Readers, &lt;br&gt;This zip file gathers together the source code for the examples in the 'Ajax in Action' book. Code is organized by chapter, and, within each chapter, subfolders ...

    cWhoisv1.52查寻域名是否注册

    Please note that if you change the filename for any of the demo pages you must rename all occurences of it in the script to match. Some domains that are supported by cWhois such as .my, .gr, .es, ....

    VB编程资源大全(英文源码 网络)

    Users must have msxml.dll version 2.0 for binary compatibility.&lt;END&gt;&lt;br&gt;46 , CustEditXML.zip Complete VB application that retrieves customer information from an XML script, allows you to make ...

    fso浏览54646465465464564

    NoPackFiles="|&lt;$datafile&gt;.mdb|&lt;$datafile&gt;.ldb|" '------------------------------------------------------------- Call Main() Set oFso=Nothing '======================== Subs Begin =======================...

Global site tag (gtag.js) - Google Analytics