note 101250 added to function.preg-replace

From: Date: Sun, 05 Dec 2010 18:51:39 +0000
Subject: note 101250 added to function.preg-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-174630@lists.php.net to get a copy of this message
/*Just something to have in mind... When using preg_replace, have in mind that variables are calculated. There is no warning issued if the variable is not defined, even when error reporting is set to E_ALL ^ E_STRICT */ //As you can see from the below example: ///------------------------------------------------------------- $text = 'The price is PRICE '; $lookFor = 'PRICE'; $replacement = '$100'; echo $replacement.'<br />'; //will display //$100 echo preg_replace('/'.$lookFor.'/', $replacement, $text).'<br />'; //Will display //The price is 0 echo str_replace($lookFor, $replacement, $text).'<br />'; //Will display //The price is $100 ///------------------------------------------------------------- ---- Server IP: 69.147.83.197 Probable Submitter: 213.149.158.240 ---- Manual Page -- http://www.php.net/manual/en/function.preg-replace.php Edit -- https://master.php.net/note/edit/101250 Del: integrated -- https://master.php.net/note/delete/101250/integrated Del: useless -- https://master.php.net/note/delete/101250/useless Del: bad code -- https://master.php.net/note/delete/101250/bad+code Del: spam -- https://master.php.net/note/delete/101250/spam Del: non-english -- https://master.php.net/note/delete/101250/non-english Del: in docs -- https://master.php.net/note/delete/101250/in+docs Del: other reasons-- https://master.php.net/note/delete/101250 Reject -- https://master.php.net/note/reject/101250 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#174630) next »