Hello,

What is the chance of support for constants in double-quoted strings
in PHP 5.3 or PHP 6.0?

This is something I have wanted for some time now.

Use cases:
Writing an SQL query that makes use of a status field
<?php
define ('STATUS_ACTIVE', 1);
define ('NUM_PER_PAGE', 25);
$q = "SELECT ID, Name FROM Projects WHERE StatusID = " . STATUS_ACTIVE
. " LIMIT " . NUM_PER_PAGE . " OFFSET {$offset}";
$res = mysql_query ($q);
?>

Syntax suggestions:
Constants would need to be contained within curly braces. e.g.
"SELECT ID, Name FROM Projects WHERE StatusID = {STATUS_ACTIVE} LIMIT
{NUM_PER_PAGE} OFFSET {$offset}"
The syntax would therefore be:
'{', one or more of [-_a-zA-Z0-9], '}'
If not constant is found, the string should be inserted directly.
If that causes too much parsing issues, perhaps a symbol should be
placed before or after the opening brace. e.g.
"SELECT ID, Name FROM Projects WHERE StatusID = {#STATUS_ACTIVE} LIMIT
#{NUM_PER_PAGE} OFFSET {$offset}"

Regards,
Josh

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to