|
|
Strings - PHP
|
Views : 267
|
|
Tagged in : PHP
|
|
|
Report This Scrap as Inappropriate We request you to choose the appropriate categroy and subcategory that suits your
objectionable concern about the scrap, So that our team can review and find out whether it violates our Guidelines or the
scrap is not suitable for all viewers.
|
Strings
1) We use single quotes around strings whenever possible (e.g. strings that don't contain variables, single quotes, n, etc.). This is supposed to make less work for the PHP parser.
2) When an array variable isn't in a string, put quotes around string-literal keys so they are not regarded as constants:
// OK
echo $row[$key];
// Wrong, unless key is a constant
echo $row[key];
// Right
echo $row['key'];
// OK, since it's in a string
echo "Text: $row[key]";
3) Remember, you can break out of PHP mode for large sections of HTML. This is faster than echo'ing and you don't need to escape quotes.
|
|
By Sanju, On - 2010-01-29 |
|
|
|