-
Today's PHP Tip
I am going to try and post a tip everyday.
This one came to my mind when I saw filburt1's code on cookies:
PHP parses strings that are enclosed in double quotes ("i will be parsed"), as opposed to those enclosed in single quotes, which are used on face value.
So If you do
<?php
$somevar = 121;
echo "I am $somevar";
?>
you get
I am 121
If the same read
<?php
$somevar = 121;
echo 'I am $somevar';
?>
you get
I am $somevar
So as an optimization, don't put code like echo "<TR><TD>" in double quotes. Put it in single, so the PHP engine doesn't have to parse it.
HTH
Thanks!
-
Nifty little tip. I forgot the String concatenation character (I thought it was + then got confused when it only printed out 0) so I had to break it up into different lines. :)
-
it's . arien ;)
echo "something " . $coolvar;
-
Yeah, I remembered that...after two weeks of messing around with PHP :p
-
yeah, php handles string concatentaion strangely, but once you get used to it it is cool.