|
-
Feb 21st, 2002, 12:47 PM
#1
Thread Starter
Member
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!
-
Feb 21st, 2002, 01:13 PM
#2
Member
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.
-
Feb 21st, 2002, 01:23 PM
#3
PowerPoster
it's . arien 
echo "something " . $coolvar;
-
Feb 21st, 2002, 02:04 PM
#4
Member
Yeah, I remembered that...after two weeks of messing around with PHP
-
Feb 21st, 2002, 04:38 PM
#5
PowerPoster
yeah, php handles string concatentaion strangely, but once you get used to it it is cool.
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|