note 41717 added to function.preg-match

From: Date: Tue, 20 Apr 2004 21:49:21 +0000
Subject: note 41717 added to function.preg-match
Groups: php.notes 
Request: Send a blank email to php-notes+get-68389@lists.php.net to get a copy of this message
As Brion noticed in a previous note, preg_match function may CRASH php apache module (it doesn't seem to happen in CLI version) if you use this function with a null pattern : <?php if( some conditions ) { $pattern = 'something'; ... } ... preg_match($pattern,$subject,$matches); // THIS MAY CRASH ! php?> To avoid crashes, be sure that $pattern has been defined before using preg_match : <?php if( some conditions ) { $pattern = 'something'; ... } ... if($pattern) { // $pattern is not null or empty preg_match($pattern,$subject,$matches); } ... php?> ---- Manual Page -- http://www.php.net/manual/en/function.preg-match.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+41717 Delete -- http://master.php.net/manage/user-notes.php?action=delete+41717&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+41717&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#68389) next »