note 115902 added to language.constants

From: Date: Sun, 12 Oct 2014 20:08:39 +0000
Subject: note 115902 added to language.constants
Groups: php.notes 
Request: Send a blank email to php-notes+get-200630@lists.php.net to get a copy of this message
There is a way to access a constant in heredoc. Here is the example: <?php define("__STR",'constant.string.defined'); function heredocGetConstant($constant) { return constant($constant); } $heredocGetConstant = 'heredocGetConstant'; $my_string = <<<EOT This is my constant printed from heredoc: {$heredocGetConstant('__STR')} EOT; echo $my_string; Output: This is my constant printed from heredoc: constant.string.defined ---- Server IP: 72.52.91.14 Probable Submitter: 188.25.166.216 ---- Manual Page -- http://php.net/manual/en/language.constants.php Edit -- https://master.php.net/note/edit/115902 Del: integrated -- https://master.php.net/note/delete/115902/integrated Del: useless -- https://master.php.net/note/delete/115902/useless Del: bad code -- https://master.php.net/note/delete/115902/bad+code Del: spam -- https://master.php.net/note/delete/115902/spam Del: non-english -- https://master.php.net/note/delete/115902/non-english Del: in docs -- https://master.php.net/note/delete/115902/in+docs Del: other reasons-- https://master.php.net/note/delete/115902 Reject -- https://master.php.net/note/reject/115902 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#200630) next »