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 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么