Doc #62997 [NEW]: Section on variables: explain $1 is always literal
| From: | php at richardneill dot org | Date: | Sun, 02 Sep 2012 14:10:57 +0000 |
| Subject: | Doc #62997 [NEW]: Section on variables: explain $1 is always literal | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-8799@lists.php.net to get a copy of this message | ||
From: php at richardneill dot org
Operating system: Linux
PHP version: Irrelevant
Package: Documentation problem
Bug Type: Documentation Problem
Bug description:Section on variables: explain $1 is always literal
Description:
------------
In something like pg_query_params(), it is OK to use eg
$sql = "select * from table where id=$1"
In other words, because variable names cannot begin with numbers,
constructs
such as $1, $2 etc are literal, even within double-quotes.
This is actually quite helpful - and it seems to be deliberate (at any
rate, no errors appear in logfile). I think the documentation should make
it clearer.
Test script:
---------------
echo 'You owe me $100';
echo "You owe me \$100";
echo "You owe me $100";
all produce the same output. The 3rd of these is (to me) rather surprising,
though useful, and isn't documented, either in the variable-naming or the
double-quoted string sections. It should also appear in the
pg_query_params() docs.
--
Edit bug report at https://bugs.php.net/bug.php?id=62997&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=62997&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=62997&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=62997&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=62997&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=62997&r=needdocs
Fixed in release: https://bugs.php.net/fix.php?id=62997&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=62997&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=62997&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=62997&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=62997&r=support
Expected behavior: https://bugs.php.net/fix.php?id=62997&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=62997&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=62997&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=62997&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=62997&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=62997&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=62997&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=62997&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=62997&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=62997&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=62997&r=mysqlcfg