#46588 [Opn->Bgs]: Support for <? ?> within NOWDOC/HEREDOC syntax
| From: | lbarnaud@php.net | Date: | Mon, 17 Nov 2008 11:07:15 +0000 |
| Subject: | #46588 [Opn->Bgs]: Support for <? ?> within NOWDOC/HEREDOC syntax | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-131025@lists.php.net to get a copy of this message | ||
ID: 46588
Updated by: lbarnaud@php.net
Reported By: vask at dmglobal dot net
-Status: Open
+Status: Bogus
Bug Type: Feature/Change Request
Operating System: Any
PHP Version: 5.2.6
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Adding this is very likely to break many existing codes.
Use this:
$it = get_it();
$sql = <<<SQL
SELECT $it LIMIT 1
SQL;
Maybe you can also fake a property that will actually call a method
(with an object using __get()):
$sql = <<<SQL
SELECT $object->get_it LIMIT 1
SQL;
Previous Comments:
------------------------------------------------------------------------
[2008-11-17 03:23:17] vask at dmglobal dot net
Description:
------------
NOWDOC/HEREDOC only allows PHP values such as those allowed within a
quoted string. Permitting PHP code (such as functions) within
NOWDOC/HEREDOC will allow more flexibility for coding. Also, when using
a text editor, syntax styling for PHP and syntax styling for another
language specified by the NOWDOC/HEREDOC within the same file would be
more readable as breaking apart the NOWDOC/HEREDOC for a function call
would no longer be necessary.
In the below examples I would like to reemphasize the importance of:
- PHP code with PHP syntax styling
- SQL code with SQL syntax styling
$sql = <<<SQL
SELECT <?= get_it(); ?> LIMIT 1
SQL;
Instead of:
$sql = <<<SQL
SELECT
SQL;
$sql .= get_it();
$sql .= <<<SQL
LIMIT 1
SQL;
Reproduce code:
---------------
$sql = <<<SQL
SELECT <?= get_it(); ?> LIMIT 1
SQL;
Expected result:
----------------
$sql = <<<SQL
SELECT <?= get_it(); ?> LIMIT 1
SQL;
Actual result:
--------------
Does NOT run.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=46588&edit=1