Unstoppable Domains โ€” Expired Auctions

Quick PHP question

NamecheapNamecheap
Watch
Impact
45
Hey guys,

I just picked up a book on PHP today.
The author does describe when to use single quotes ( ' ' ) and when to use double quotes ( " " ). Like he said to use double quotes when the variable $PHP_SELF was being used.

I'm a bit lost on it though and I was wondering if someone could help me out here on when it's a good time to use single quotes and when to use double quotes and what they should be used with.

Any help would be appreciated,
Thanks :)
-Andy
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
"" allows you to us multiple lines and '' does not.

U can get away with using both with out having any issues. Just depends on how you want things to look when you view the source in a browser.
 
0
•••
double quotes parse variables.
single quotes do not
PHP:
<?php
$user = 'bob'; // uses single quotes because there is no variable
// hello, bob.
echo "hello, $user."; // the correct method would be: echo "hello, {$user}.";
// hello, $user.
echo 'hello, $user.';
?>

if you don't need to parse a variable in a string, use single quotes. otherwise use double quotes.

http://us3.php.net/types.string
 
0
•••
Aha, that makes more sense now.

Thank you guys, :)
-Andy
 
0
•••
Although some people will prefer single quotes, you can still use a variable the following way

echo 'Welcome, ' . $username;

Good luck.
 
0
•••
Hi ppl,

I just wanted to know if is it possible to parse variables with single quotes cause
i tried it and both work for i think single quote don't need to be escaped in
double quote and vise versa.
 
0
•••
generally speaking you should always use double quotes with \ to escape special meaning

you can use single quotes but its messy and will cause problems in some situtations
 
0
•••
Dynadot โ€” .com TransferDynadot โ€” .com Transfer
CatchedCatched
Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back