dongxiaolin2801 2015-06-30 20:18
浏览 61
已采纳

php preg_replace_all我需要定义$ matches吗?

I typically call preg_match_all using $pattern, $subject, $matches, like

preg_match_all("/\S/","words",$matches);

However, my IDE (Netbeans) is yelling at me because $matches (which is passed by reference and will be assigned the result of preg_match_all) is undefined so it doesn't want me to pass it as a parameter. Its happy with something like:

$matches=[];
preg_match_all("/\S/","words",$matches);

However, this seems superfluous, and the examples on php.net do not define the variable ahead of time. What is the "proper" way to do this? Can I just ignore Netbeans?

  • 写回答

2条回答 默认 最新

  • douxiza9868 2015-06-30 20:29
    关注

    Ignore NetBeans. As you say, the PHP manual doesn't define the variable, and I've tested it with all error reporting on and no notice error is given.

    Also, the IDE I use, PHPStorm, doesn't show an undefined error for the $matches variable.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应