#46588 [Bgs]: Support for <? ?> within NOWDOC/HEREDOC syntax
| From: | vask at dmglobal dot net | Date: | Tue, 18 Nov 2008 06:05:33 +0000 |
| Subject: | #46588 [Bgs]: Support for <? ?> within NOWDOC/HEREDOC syntax | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-131061@lists.php.net to get a copy of this message | ||
ID: 46588
User updated by: vask at dmglobal dot net
Reported By: vask at dmglobal dot net
Status: Bogus
Bug Type: Feature/Change Request
Operating System: Any
PHP Version: 5.2.6
New Comment:
Thanks for the reply and suggestions...
However, HEREDOC/NOWDOC or maybe even a WHATEVERDOC would be more
FLEXIBLE and INTUITIVE if the entire part inside was essentially treated
as a separate file. Thus allowing:
$sql = <<<SQL
SELECT <?= get_it(); ?> LIMIT 1
SQL;
The reason I though this would be possible is because unlike quoted
strings NOWDOC/HEREDOC doesn't require you to escape quotations.
Previous Comments:
------------------------------------------------------------------------
[2008-11-17 11:07:14] lbarnaud@php.net
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;
------------------------------------------------------------------------
[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