note 110937 added to language.operators.string

From: Date: Wed, 26 Dec 2012 22:22:05 +0000
Subject: note 110937 added to language.operators.string
Groups: php.notes 
Request: Send a blank email to php-notes+get-192682@lists.php.net to get a copy of this message
As for me, curly braces serve good substitution for concatenation, and they are quicker to type and code looks cleaner. Remember to use double quotes (" ") as their content is parced by php, because in single quotes (' ') you'll get litaral name of variable provided: <?php $a = '12345'; // This works: echo "qwe{$a}rty"; // qwe12345rty, using braces echo "qwe" . $a . "rty"; // qwe12345rty, concatenation used // Does not work: echo 'qwe{$a}rty'; // qwe{$a}rty, single quotes are not parsed echo "qwe$arty"; // qwe, because $a became $arty, which is undefined ?> ---- Server IP: 69.147.83.199 Probable Submitter: 91.213.119.254 ---- Manual Page -- http://php.net/manual/en/language.operators.string.php Edit -- https://master.php.net/note/edit/110937 Del: integrated -- https://master.php.net/note/delete/110937/integrated Del: useless -- https://master.php.net/note/delete/110937/useless Del: bad code -- https://master.php.net/note/delete/110937/bad+code Del: spam -- https://master.php.net/note/delete/110937/spam Del: non-english -- https://master.php.net/note/delete/110937/non-english Del: in docs -- https://master.php.net/note/delete/110937/in+docs Del: other reasons-- https://master.php.net/note/delete/110937 Reject -- https://master.php.net/note/reject/110937 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#192682) next »