the curly wrapper is pretty old, as I can remember using it in PHP4.
I read about the curly brackets in arrays in some book. It was suggested to be the PHP5 method of accessing array indexes. And as fas as I know it works, not sure if it will be finally adopted or if it will actually enhances performance for there is not much about it in the php manuals. But the following can be found on the subject using the following page in the php manual.
http://www.php.net/manual/en/language.types.string.phpabout the array indexCharacters within strings may be accessed and modified by specifying the zero-based offset of the desired character after the string using square array brackets, as in $str[42]. Think of a string as an array of characters for this purpose. The functions substr() and substr_replace() can be used when you want to extract or replace more than 1 character.
Note: Strings may also be accessed using braces, as in $str{42}, for the same purpose.About curly..
$great = 'fantastic';
// Won't work, outputs: This is { fantastic}
echo "This is { $great}";
// Works, outputs: This is fantastic
echo "This is {$great}";
echo "This is ${great}";
// Works
echo "This square is {$square->width}00 centimeters broad.";
// Works, quoted keys only work using the curly brace syntax
echo "This works: {$arr['key']}";
// Works
echo "This works: {$arr[4][3]}";
// This is wrong for the same reason as $foo[bar] is wrong outside a string.
// In other words, it will still work, but only because PHP first looks for a
// constant named foo; an error of level E_NOTICE (undefined constant) will be
// thrown.
echo "This is wrong: {$arr[foo][3]}";
// Works. When using multi-dimensional arrays, always use braces around arrays
// when inside of strings
echo "This works: {$arr['foo'][3]}";
// Works.
echo "This works: " . $arr['foo'][3];
echo "This works too: {$obj->values[3]->name}";
echo "This is the value of the var named $name: {${$name}}";
echo "This is the value of the var named by the return value of getName(): {${getName()}}";
echo "This is the value of the var named by the return value of \$object->getName(): {${$object->getName()}}";
// Won't work, outputs: This is the return value of getName(): {getName()}
echo "This is the return value of getName(): {getName()}";
- $great = 'fantastic';
-
- // Won't work, outputs: This is { fantastic}
- echo "This is { $great}";
-
- // Works, outputs: This is fantastic
- echo "This is {$great}";
- echo "This is ${great}";
-
- // Works
- echo "This square is {$square->width}00 centimeters broad.";
-
-
- // Works, quoted keys only work using the curly brace syntax
- echo "This works: {$arr['key']}";
-
-
- // Works
- echo "This works: {$arr[4][3]}";
-
- // This is wrong for the same reason as $foo[bar] is wrong outside a string.
- // In other words, it will still work, but only because PHP first looks for a
- // constant named foo; an error of level E_NOTICE (undefined constant) will be
- // thrown.
- echo "This is wrong: {$arr[foo][3]}";
-
- // Works. When using multi-dimensional arrays, always use braces around arrays
- // when inside of strings
- echo "This works: {$arr['foo'][3]}";
-
- // Works.
- echo "This works: " . $arr['foo'][3];
-
- echo "This works too: {$obj->values[3]->name}";
-
- echo "This is the value of the var named $name: {${$name}}";
-
- echo "This is the value of the var named by the return value of getName(): {${getName()}}";
-
- echo "This is the value of the var named by the return value of \$object->getName(): {${$object->getName()}}";
-
- // Won't work, outputs: This is the return value of getName(): {getName()}
- echo "This is the return value of getName(): {getName()}";
-
Using the correct mysql resultset parser will surly improve memory usage, simply because you are generating and popping less information into your arrays.
Using the curly wrapper instead of escapes is part of the PHP complex syntax.
Rgrds, Chris
1 + 1 = 10 + 1 = 11 + 11 = 110