V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
whatisnew
V2EX  ›  PHP

PHP error_reporting 很不理解。。。

  •  
  •   whatisnew · 2016-04-05 14:05:07 +08:00 · 1803 次点击
    这是一个创建于 3145 天前的主题,其中的信息可能已经有所发展或是发生改变。

    $aaa 是一个没有定义过的变量,下面两种情况一个报错一个不报错,奇怪。。。

    // 不报错
    if ($aaa) {}
    
    // 报: Undefined variable: aaaa
    if ($aaa)
    
    7 条回复    2016-04-05 14:27:28 +08:00
    UnisandK
        1
    UnisandK  
       2016-04-05 14:10:41 +08:00
    Nicksxs
        2
    Nicksxs  
       2016-04-05 14:11:45 +08:00
    @UnisandK 这是什么 ide
    UnisandK
        3
    UnisandK  
       2016-04-05 14:13:19 +08:00
    dapang1221
        4
    dapang1221  
       2016-04-05 14:14:35 +08:00
    刚刚试了下, if ($aaa) {} 也会报啊……
    dapang1221
        5
    dapang1221  
       2016-04-05 14:16:09 +08:00
    散了散了,题主傻了……
    whatisnew
        6
    whatisnew  
    OP
       2016-04-05 14:26:11 +08:00
    @dapang1221 抱歉,是用的框架的问题,哈哈
    gordon1986
        7
    gordon1986  
       2016-04-05 14:27:28 +08:00
    跟你 php.ini 的 error_reporting 有关。
    ; Error Level Constants:
    ; E_ALL - All errors and warnings (includes E_STRICT as of PHP 5.4.0)
    ; E_ERROR - fatal run-time errors
    ; E_RECOVERABLE_ERROR - almost fatal run-time errors
    ; E_WARNING - run-time warnings (non-fatal errors)
    ; E_PARSE - compile-time parse errors
    ; E_NOTICE - run-time notices (these are warnings which often result
    ; from a bug in your code, but it's possible that it was
    ; intentional (e.g., using an uninitialized variable and
    ; relying on the fact it is automatically initialized to an
    ; empty string)
    ; E_STRICT - run-time notices, enable to have PHP suggest changes
    ; to your code which will ensure the best interoperability
    ; and forward compatibility of your code
    ; E_CORE_ERROR - fatal errors that occur during PHP's initial startup
    ; E_CORE_WARNING - warnings (non-fatal errors) that occur during PHP's
    ; initial startup
    ; E_COMPILE_ERROR - fatal compile-time errors
    ; E_COMPILE_WARNING - compile-time warnings (non-fatal errors)
    ; E_USER_ERROR - user-generated error message
    ; E_USER_WARNING - user-generated warning message
    ; E_USER_NOTICE - user-generated notice message
    ; E_DEPRECATED - warn about code that will not work in future versions
    ; of PHP
    ; E_USER_DEPRECATED - user-generated deprecation warnings
    ;
    ; Common Values:
    ; E_ALL (Show all errors, warnings and notices including coding standards.)
    ; E_ALL & ~E_NOTICE (Show all errors, except for notices)
    ; E_ALL & ~E_NOTICE & ~E_STRICT (Show all errors, except for notices and coding standards warnings.)
    ; E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR (Show only errors)
    ; Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
    ; Development Value: E_ALL
    ; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT
    ; http://php.net/error-reporting
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5218 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 01:17 · PVG 09:17 · LAX 17:17 · JFK 20:17
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.