zoukankan      html  css  js  c++  java
  • PHP define() 定义常量

    PHP define()函数定义了运行时的常量,

    具体语法如下所示:

    (PHP 4, PHP 5, PHP 7)

    define — Defines a named constant

    bool define ( string $name , mixed $value [, bool $case_insensitive = FALSE ] )

    Defines a named constant at runtime.

    define() 函数的参数说明:

    $name 表示常量名称,

    $value 表示对应的常量值,在PHP5版本中,常量值只能是integerfloatstringboolean, or NULL这几种类型的值,

    到了PHP7,常量值可以为数组,

    $case_insensitive 代表常量名是否区分大小写,默认为FALSE时,是不区分大小写的,设置为TRUE时表示区分大小写。

    define() 的返回值为true时表示常量定义成功,为false时表示定义失败。

    Example:

    <?php
    define("CONSTANT", "Hello world.");
    echo CONSTANT; // outputs "Hello world."
    echo Constant; // outputs "Constant" and issues a notice.
    
    define("GREETING", "Hello you.", true);
    echo GREETING; // outputs "Hello you."
    echo Greeting; // outputs "Hello you."
    
    // Works as of PHP 7
    define('ANIMALS', array(
        'dog',
        'cat',
        'bird'
    ));
    echo ANIMALS[1]; // outputs "cat"
    
    ?>
  • 相关阅读:
    Jenkins+ant循环执行jmeter文件
    Jmeter接口模版说明
    jenkins与远程服务器配置SSH免密登录
    xcode developer tools简介
    MySQL之模糊查询
    MySQL排名函数
    openblas下载安装与使用
    CVX安装使用
    AMD包下载及使用
    Python及相应软件安装
  • 原文地址:https://www.cnblogs.com/ryanzheng/p/9044013.html
Copyright © 2011-2022 走看看