• PHP选项、信息函数(转)


    bool assert ( mixed $assertion [, string $description ] ) — 检查一个断言是否为 FALSE

    复制代码
     1 assert_options(ASSERT_ACTIVE, true);//允许使用assert()函数
     2 assert_options(ASSERT_WARNING, false);//在assert失败时不输出警告信息
     3 assert_options(ASSERT_BAIL, true);//assert失败后终止代码执行
     4 assert_options(ASSERT_CALLBACK, 'getMsg');//assert失败后终止代码执行。
     5 
     6 echo '开始:<br/>';
     7 assert('mysql_query("")');
     8 echo '测试成功!';
     9 
    10 function getMsg(){
    11     echo '出错啦!';
    12 }
    复制代码

     mixed assert_options ( int $what [, mixed $value ] ) — 设置 assert() 的各种控制选项,或者查询当前的设置

    ASSERT_ACTIVE : 是否启用 assert() 断言, ini配置 assert.active,默认值 1

    ASSERT_WARNING :是否为每个失败的断言产生一个 PHP 警告,ini配置 assert.warning,默认1

    ASSERT_BAIL :是否在断言失败时中止执行,ini配置 assert.bail,默认值0

    ASSERT_QUIET_EVAL :是否在断言表达式求值时禁用 error_reporting,ini配置assert.quiet_eval,默认值0

    ASSERT_CALLBACK :断言失败时调用回调函数,ini配置assert.callback

    复制代码
     1 assert_options(ASSERT_ACTIVE, true);//允许使用assert()函数
     2 assert_options(ASSERT_WARNING, false);//在assert失败时不输出警告信息
     3 assert_options(ASSERT_BAIL, true);//assert失败后终止代码执行
     4 assert_options(ASSERT_CALLBACK, 'getMsg');//assert失败后终止代码执行。
     5 
     6 echo '开始:<br/>';
     7 assert(is_int(1.2));//检测结果为fales
     8 echo '测试成功!';
     9 
    10 function getMsg(){
    11     echo '出错啦!';
    12 }
    复制代码

    bool dl( string $library ) — 获取 PHP 配置选项的值 载入指定的 PHP扩展

    1 if(!extension_loaded('sqlite')){//测试指定的扩展是否已经激活
    2     $prefix = (PHP_SHLIB_SUFFIX === 'dll') ? 'php_' : '';
    3     dl($prefix . 'sqlite.' . PHP_SHLIB_SUFFIX);
    4 }

    int gc_collect_cycles() — 强制收集所有现存的垃圾循环周期

    void gc_disable ( void ) — 停用循环引用收集器

    void gc_enable ( void ) — 激活循环引用收集器

    bool gc_enabled ( void ) — 返回循环引用计数器的状态

    string get_cfg_var ( string $option ) — 获取 PHP 配置选项的值获取 PHP 配置选项的值

    string get_current_user ( void )— 获取当前 PHP 脚本所有者名称

    array get_defined_constants ([ bool $categorize = false ] )— 返回所有常量的关联数组

    array get_extension_funcs ( string $module_name )— 返回模块函数名称的数组

    print_r(get_extension_funcs("xml"));

    string get_include_path ( void ) — 获取当前的 include_path 配置选项

    array get_included_files ( void )— 返回被 include 和 require 文件名的 array

    复制代码
     1 include 'test1.php';
     2 include_once 'test2.php';
     3 require 'test3.php';
     4 require_once 'test4.php';
     5 
     6 $included_files = get_included_files();
     7 
     8 foreach ($included_files as $filename){
     9     echo "$filename\n";
    10 }
    复制代码

    array get_loaded_extensions ([ bool $zend_extensions = false ] )— 返回所有编译并加载模块名的 array

    bool get_magic_quotes_gpc ( void )— 获取当前 magic_quotes_gpc 的配置选项设置

    bool get_magic_quotes_runtime ( void ) — 获取当前 magic_quotes_runtime 配置选项的激活状态

    string getenv ( string $varname ) — 获取一个环境变量的值

    $ip = getenv('REMOTE_ADDR');

    int getlastmod ( void )— 获取页面最后修改的时间

    int getmygid ( void )— 获取当前 PHP 脚本拥有者的 GID

    int getmyinode ( void )— 获取当前脚本的索引节点(inode)

    int getmypid ( void )— 获取 PHP 进程的 ID

    int getmyuid ( void )— 获取 PHP 脚本所有者的 UID

    array getopt ( string $options [, array $longopts ] )— 从命令行参数列表中获取选项

    array getrusage ([ int $who = 0 ] ) — 获取当前资源使用状况

    array ini_get_all ([ string $extension [, bool $details = true ]] ) — 获取所有配置选项

    print_r(ini_get_all("pcre"));
    print_r(ini_get_all());

    string ini_get ( string $varname ) — 获取一个配置选项的值

    void ini_restore ( string $varname )— 恢复配置选项的默认值

    string ini_set ( string $varname , string $newvalue )— 为一个配置选项设置值

    main — 虚拟的 main()int memory_get_peak_usage ([ bool $real_usage = false ] )— 返回分配给 PHP 内存的峰值int memory_get_usage ([bool $real_usage = false ] ) — 返回分配给 PHP 的内存量

    string php_ini_loaded_file ( void ) — 取得已加载的 php.ini 文件的路径

    string php_ini_scanned_files ( void )— 返回从额外 ini 目录里解析的 .ini 文件列表

    string php_sapi_name ( void ) — 返回 web 服务器和 PHP 之间的接口类型

    string php_uname ([ string $mode = "a" ] )— 返回运行 PHP 的系统的有关信息

    • 'a':此为默认all。
    • 's':操作系统名称
    • 'n':主机名。例如: localhost.example.com
    • 'r':版本名称,例如: 5.1.2-RELEASE
    • 'v':版本信息。操作系统之间有很大的不同。
    • 'm':机器类型。例如:i386

    bool phpcredits ([ int $flag = CREDITS_ALL ] ) — 打印 PHP 贡献者名单

    CREDITS_ALL :所有的

    CREDITS_DOCS : 文档组贡献名单

    CREDITS_FULLPAGE : 常用于和其他标志进行组合。 表示需要打印包含其他标志表示信息的独立 HTML 页面。

    CREDITS_GENERAL : 普遍名单:语言设计与理念、PHP作者以及 SAPI 模块

    CREDITS_GROUP : 核心开发者名单

    CREDITS_MODULES : PHP 扩展模块以及作者

    CREDITS_SAPI : PHP 的服务器 API 模块以及作者

    phpcredits(CREDITS_GROUP | CREDITS_DOCS | CREDITS_FULLPAGE);

    bool phpinfo ([ int $what = INFO_ALL ] ) — 输出关于 PHP 配置的信息

    string phpversion ([ string $extension ] ) — 获取当前的PHP版本

    bool putenv ( string $setting )— 设置环境变量的值

    void restore_include_path ( void ) — 还原 include_path 配置选项的值

    string set_include_path ( string $new_include_path ) — 设置 include_path 配置选项

    void set_time_limit ( int $seconds )— 设置脚本最大执行时间,从它本身开始计时,0表示不限时

    string sys_get_temp_dir ( void ) — 返回用于临时文件的目录

    mixed version_compare ( string $version1 , string $version2 [, string $operator ] ) — 对比两个PHP 规范化的版本数字字串

    if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
        echo '我的PHP版本很高: ' . PHP_VERSION . "\n";
    }

    int zend_thread_id ( void ) — 返回当前线程的唯一识别符

    string zend_version ( void ) — 获取当前 Zend 引擎的版本

  • 相关阅读:
    Java入门——day42
    第六周进度报告
    Java入门——day41
    Java入门——day40
    Java入门——day39
    Java入门——day38
    Java入门——day37
    Java入门——day36
    Java入门——day35
    第五周进度报告
  • 原文地址:https://www.cnblogs.com/xingmeng/p/2960543.html
Copyright © 2020-2023  润新知