time()函数将返回从1970-1-1 0:0:0到当前时间的秒数。(整型)

dirname(__FILE__)

php中定义了一个很有用的常数,即

__file__

这个内定常数是当前php程序的就是完整路径(路径+文件名)。

即使这个文件被其他文件引用(include或require),__file__始终是它所在文件的完整路径,而不是引用它的那个文件完整路径。

请看下面例子:
/home/data/demo/test/a.php

<?php
$the_full_name=__FILE__;
$the_dir=dirname(__FILE__);
echo $the_full_name; //返回/home/data/demo/test/a.php
echo $the_dir;            //返回/home/data/demo/test
?>

home/data/demo/b.php 
<?php include "test/a.php";
echo $the_full_name; //返回/home/data/demo/
echo $the_dir;            //返回/home/data/demo/test 而不是/home/data/demo/
?>test/a.php 而不是/home/data/demo/b.php

简单地说:
      __FILE__     返回当前 路径+文件名
      dirname(__FILE__) 返回当前文件路径的 路径部分
      dirname(dirname(__FILE__));得到的是文件上一层目录名(不含最后一个“/”号)

例如,当前文件是 /home/data/demo/test.php ,则 
__FILE__ 得到的就是完整路径       即 /home/data/demo/test.php ,而
dirname(__FILE__)得到路径部分   即 /home/data/demo     (后面没有“/”号)

time()函数,dirname(__FILE__) 的使用总结的更多相关文章

  1. Python os.path.dirname(__file__) 与 Python os.path.abspath(__file__) 与 os.system() 函数

    Python  os.path.dirname(__file__) 与 Python os.path.abspath(__file__) 的区别 os.path.abspath(__file__)返回 ...

  2. ****php:require_once(dirname(__FILE__)."/./config_uc.php");

    Q:麻烦清楚地讲解一下这句的意思,具体路径是怎样的,这个文解在 根目录,如果我想放在根目录下的tieba文件夹里,应该怎么修改/./ 这个是表示什么? A: require_once(dirname( ...

  3. substr(dirname(__FILE__))

    这是discuz中定义论坛安装根目录的一个常量.现在我们就来分析一下这个很简单但是非常实用的常量.     define('DISCUZ_ROOT', substr(dirname(__FILE__) ...

  4. PHP中define()和dirname(__FILE__)

    1,define() 函数定义一个常量.常量类似变量,不同之处在于: (1)在设定以后,常量的值无法更改 (2)常量名不需要开头的美元符号 ($) (3)作用域不影响对常量的访问 (4)常量值只能是字 ...

  5. Python os.path.dirname(__file__) os.path.join(str,str)

    Python os.path.dirname(__file__) Python os.path.join(str,str)   (1).当"print os.path.dirname(__f ...

  6. os.path.dirname(__file__)使用

    os.path.dirname(__file__)使用 该测试脚本所在的位置:D:\第1层\第2层\第3层\第4层\第5层\test11.py test11.py import os #该文件所在位置 ...

  7. dirname(__FILE__)

    dirname() 函数返回路径中的目录部分. __FILE__ :被称为PHP魔术常量,返回当前执行PHP脚本的完整路径和文件名,包含一个绝对路径 dirname(__FILE__) 函数返回的是脚 ...

  8. Python——os.path.dirname(__file__) 与 os.path.join(str,str)

    Python os.path.dirname(__file__) Python os.path.join(str,str)   (1).当"print os.path.dirname(__f ...

  9. PHP获取绝对路径dirname(__FILE__)和__DIR__比较

    我们都知道,要获取当前PHP脚本所在目录的绝对路径,dirname(__FILE__) 和 __DIR__都可以实现.那么什么情况下用 dirname(__FILE__),什么情况下用 __DIR__ ...

随机推荐

  1. Java排序算法——冒泡排序

    import java.util.Arrays; //================================================= // File Name : Bubble_S ...

  2. codeforces 711B - Chris and Magic Square(矩阵0位置填数)

    题目链接:http://codeforces.com/problemset/problem/711/B 题目大意: 输入 n ,输入 n*n 的矩阵,有一个占位 0 , 求得将 0 位置换成其他的整数 ...

  3. centos6.5编译安装git

    1.下载高版本的git,地址:https://github.com/git/git/release,选择git-2.9.3.tar.gz 2.安装依赖包.解压.编译安装 yum install cur ...

  4. yourphp点击刷新验证码

    加入css <script type="text/javascript" src="./Public/Js/my.js"></script&g ...

  5. hibernate4中使用Session doWork()方法进行jdbc操作(代码)

    Hibernate3.3.2版本中getSession().connection()已被弃用,hibernate4中官方推荐使用Session doWork()方法进行jdbc操作 首先看看Work接 ...

  6. 使用CFURLCreateStringByAddingPercentEscapes进行URL编码

    iOS程序访问HTTP资源时需要对URL进行UTF8编码,特酷吧在之前一直都喜欢使用NSString的stringByAddingPercentEscapesUsingEncoding方法进行编码.今 ...

  7. 【转】asp.net mvc 页面跳转

    1.使用传统的Response.Redirect例如string url = "/account/create";Response.Redirect(url); 1.Server. ...

  8. PHP如何实现页面静态化

    1.file_put_contents()函数 2.fwrite()函数 3.使用PHP内置缓存机制实现页面静态化-output_buffering

  9. Reading Famous blog to prevent me wasting time on blind wandering

    I can`t help surfing the useless bbs and some other kind of SNS. The time I begin to do it, it costs ...

  10. Redis数据库的使用与介绍

    本周11-15号开始用Redis数据库在现有的平台基础上开发一个独立模块,这是一个边学习.边记录.边交流.边开发.边总结的过程.大部分随笔都是个人的“工作日志”,旨在记录自己学习过程中收集的一些资料, ...