Thread: " " vs ' '
View Single Post
  #2  
Old 08-25-2006, 09:44 AM
jacques jacques is offline
OSP Starters
 
Join Date: Mar 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
jacques is on a distinguished road
Default

Double quotes can be used so you can include a variable in your string:

Code:
$somevar = 'John';
echo "Hello $somevar, have a good day!";

Single quotes offer no such support.


Code:
$somevar = 'John';
echo 'Hello $somevar, have a good day!';

Would throw up an error.

When dealing with a straight string, no variables or anything, it's best to use single quotes because double quotes tells PHP to look for variables and parse them correctly. It saves PHP a little bit of time.


Cheers -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
  Webmaster Forums - View Single Post - " " vs ' '
Thread: " " vs ' '
View Single Post
  #2  
Old 08-25-2006, 09:44 AM
jacques jacques is offline
OSP Starters
 
Join Date: Mar 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
jacques is on a distinguished road
Default

Double quotes can be used so you can include a variable in your string:

Code:
$somevar = 'John';
echo "Hello $somevar, have a good day!";

Single quotes offer no such support.


Code:
$somevar = 'John';
echo 'Hello $somevar, have a good day!';

Would throw up an error.

When dealing with a straight string, no variables or anything, it's best to use single quotes because double quotes tells PHP to look for variables and parse them correctly. It saves PHP a little bit of time.


Cheers -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote