Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:41543 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 88162 invoked from network); 29 Oct 2008 06:53:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Oct 2008 06:53:28 -0000 Authentication-Results: pb1.pair.com header.from=arvids.godjuks@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=arvids.godjuks@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 66.249.92.169 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: arvids.godjuks@gmail.com X-Host-Fingerprint: 66.249.92.169 ug-out-1314.google.com Received: from [66.249.92.169] ([66.249.92.169:22839] helo=ug-out-1314.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D6/76-48169-76808094 for ; Wed, 29 Oct 2008 01:53:28 -0500 Received: by ug-out-1314.google.com with SMTP id 39so505367ugf.37 for ; Tue, 28 Oct 2008 23:53:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type:references; bh=xhaNWjBgg+9wQZTCc9QryvRv8bCkxAJQMl8Uc5+amiw=; b=MVVrwGbuTfxQJR06CTbo6oJftY5y9HnxsTd2/aA8o82HQNP2qg9JPplzke02Dqzwv1 HEL7Q9VzqoLRNO8SwcnzI4pRiwCbCXdGvovcHm/Er+m5YQrspKtV5LN8vAN0tv7pr4mK MMzDsq2aCE8x2aNvApu4JDu4jl52dJvbWsA70= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:references; b=jJNKdyZ2DqwcP8SYGiCJ2p5KA25SZuTIdG6Yp4+Xqm9AdUjVji5Lrm9ixegTnEEflE 9U3uTsvE5TwlrB8jkWZusTNMViC5wBd2cz6YZj71E+msUmPhtz0pQlgvkLfuM7EvsZpE I9ni+9FyGhcNJwzKVbPDAuR373k/5Q491y0k8= Received: by 10.67.116.11 with SMTP id t11mr291073ugm.56.1225263203058; Tue, 28 Oct 2008 23:53:23 -0700 (PDT) Received: by 10.67.25.15 with HTTP; Tue, 28 Oct 2008 23:53:23 -0700 (PDT) Message-ID: <9b3df6a50810282353oaedfde5qf62df50876760170@mail.gmail.com> Date: Wed, 29 Oct 2008 08:53:23 +0200 To: Josh Cc: internals@lists.php.net In-Reply-To: <6fef9b880810282117v569d3064l752902daaa285a25@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_64413_5394185.1225263203077" References: <6fef9b880810282117v569d3064l752902daaa285a25@mail.gmail.com> Subject: Re: [PHP-DEV] Constants in double-quoted strings From: arvids.godjuks@gmail.com ("Arvids Godjuks") ------=_Part_64413_5394185.1225263203077 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline People, when you will start to learn that such approach is a mess? First, use ' ' instead of " " and format your SQL better and you woun't have any problems: a). It's more readable without syntax highlighting b). It's just faster. c). It's a good style. d). I think if that is easy to do, it would be implemented a long time ago. 2008/10/29 Josh > 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 > 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 > > ------=_Part_64413_5394185.1225263203077--