1. Home
  2. Docs
  3. php

php

php7

  • Trait PHP 解释器在编译代码时会把 Trait 部分代码复制粘贴到类的定义体中,但是不会处理这个操作引入的不兼容问题
  • use function 引用指定文件的方法
  • ?? 当变量没定义或是null有效果

Nullable Type(可为空类型)

function test(?string $name = null)
{
    var_dump($name);
}

test('tpunt');
test(null); // ok
test(); // ok

16进制位运算

    /**
     * 设备机器解析版本号
     * @param $ver
     * @return mixed
     */
    static function decryptVersion($ver)
    {
        $version ['cpu'] = ($ver>>24)&0xff; // 设备号
        $version ['board'] = ($ver>>16)&0xff;
        $version ['ver'] = $ver&0xff;
        return $version;
    }

可为空(Nullable)类型

相关资料

Trait 的概念和用法

multiple-php-versions-mac多版本php共存

Articles

Was this article helpful to you? Yes No

How can we help?