» Quick Links
You can make money on these forums
We Share profits with you
Google
Google Adsense
Google Adwords
YPN
Yahoo
MSN Search
Web Directories
Web Hosting
Web Hosting Offers
Hosting News
Suggestions
Link Building
Domain Names
PHP Forums
MySQL Forums
» More Links
OSP News
Reseller Hosting
Shared Hosting
Dedicated Servers
Google Adsense
Search Engine Marketing
Link Development
Affiliate Marketing


» Advertising
Multiple DC PR Check

Free SEO Tools


Go Back   Webmaster Forums > Website Developement / Programming > PHP Programming and Tips

PHP Programming and Tips Discuss about PHP programming and Share Tips. Ask questions about Scripting and Errors.

Reply
 
Thread Tools Display Modes
  #1  
Old 08-25-2006, 09:41 AM
nelson nelson is offline
OSP Starters
 
Join Date: Aug 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
nelson is on a distinguished road
Default " " vs ' '

I sorta been wondering what the true difference to php is between "" and ''. in some cases you can use them interchangebly and in other places you cant. i like to thing that " and " refers to a string of text and ' and ' refer to a single character but this isnt always the case.


Waiting for your replies -- 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
Revenue Sharing Ads ( ?):
  #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
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 03:23 AM.