douxin20081125 2013-12-17 01:00 采纳率: 0%
浏览 31
已采纳

如何在我的开发服务器上启用通知 - 不工作

I'm referring to How to enable notices on my development server

I expect the following code shall give me some warning, when I execute it through, as my $a is not explicitly declared as array

php a.php

<?php

ini_set('display_errors', 1);
error_reporting(E_NOTICE);

$a['key'] = 123;
echo $a['key'] . "
";   

However, no warning message being printed. Is there anything I had missed?

The PHP I'm using is PHP 5.5.3. I'm not sure this matters?

  • 写回答

1条回答 默认 最新

  • duanjia4097 2013-12-17 01:04
    关注

    I expect the following code shall give me some warning, when I execute it through, as my $a is not explicitly declared as array

    Wrong... by writing $a['key'] = 123; you declare an array and set the key key to the integer number 123. That's a valid PHP array initialization. (The PHP version does not matter in this case.)

    To explicitely produce an error notice for testing purposes…

    If you want to provoke an error notice for testing purposes, you could add this line:

    count($ThisIsNotDefinedOnPurpose);    
    

    which will produce an error notice saying

    Notice: Undefined variable: ThisIsNotDefinedOnPurpose in … on line …
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大