note 92831 added to function.explode

From: Date: Tue, 11 Aug 2009 05:55:26 +0000
Subject: note 92831 added to function.explode
Groups: php.notes 
Request: Send a blank email to php-notes+get-159309@lists.php.net to get a copy of this message
If you are exploding string literals in your code that have a dollar sign ($) in it, be sure to use single-quotes instead of double-quotes, since php will not spare any chance to interpret the variable-friendly characters after the dollar signs as variables, leading to unintended consequences, the most typical being missing characters. <?php $doubleAr = explode(" ", "The $quick brown fox"); $singleAr = explode(" ", 'The $quick brown fox'); echo $doubleAr[1]; // prints ""; echo $singleAr[1]; // prints "$quick"; ?> ---- Server IP: 209.41.74.194 Probable Submitter: 24.89.23.67 ---- Manual Page -- http://www.php.net/manual/en/function.explode.php Edit -- https://master.php.net/note/edit/92831 Del: integrated -- https://master.php.net/note/delete/92831/integrated Del: useless -- https://master.php.net/note/delete/92831/useless Del: bad code -- https://master.php.net/note/delete/92831/bad+code Del: spam -- https://master.php.net/note/delete/92831/spam Del: non-english -- https://master.php.net/note/delete/92831/non-english Del: in docs -- https://master.php.net/note/delete/92831/in+docs Del: other reasons-- https://master.php.net/note/delete/92831 Reject -- https://master.php.net/note/reject/92831 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#159309) next »