zoukankan      html  css  js  c++  java
  • PHP Warning: Unsupported declare 'strict_types' in ...

    Fatal error: strict_types declaration must be the very first statement in the script in *.php on line *
    Parse error: syntax error, unexpected 'declare' (T_DECLARE) in *.php on line *

    PHP强类型是从PHP 7.0开始支持的,使用declare(strict_types=1)来声明脚本中的函数调用使用强类型变量及返回值,declare(strict_types=1)必须作为脚本的第一句PHP代码,如果定义函数的脚本中使用了declare(strict_types=1),而调用函数的脚本中没有使用,强类型声明无效,强类型声明只影响函数调用有,对其他语法没有影响,在declare(strict_types=1)以后,false == 0 == '' == null == array() 1 == true 之类的表达式仍然成立。

    不能在declare(strict_types=1)前使用@,写作@declare(strict_types=1);否则会报错Parse error: syntax error, unexpected 'declare' (T_DECLARE) in *.php on line *.

    如果declare(strict_types=1);不是所在PHP脚本文件中的第一句有效的PHP代码,会报错Fatal error: strict_types declaration must be the very first statement in the script in *.php on line *.

    如果PHP版本低于7.0.0,会报错Warning: Unsupported declare 'strict_types' in *.php on line *.

  • 相关阅读:
    codevs1127
    codevs1041
    C#预处理指令
    C#基本语句与C++区别
    iOS.TextKit.01.凸版印刷效果
    iOS.常用设计模式.02.委托模式
    iOS.常用设计模式.01.单例模式
    iOS.iPad.03.UIModal
    iOS.iPad.02.UIPopoverViewController
    iOS.iPad.01.UISplitViewController
  • 原文地址:https://www.cnblogs.com/yimingwang/p/13279706.html
Copyright © 2011-2022 走看看