The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. November 21, 2008, 11:59:02 AM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: single quotes and newlines  (Read 549 times)
jammaster82
Expert
****
Offline Offline

Posts: 293

bloody hacker


View Profile WWW
« on: May 10, 2008, 10:58:48 AM »

Okay so i just found out that \n for new line
does not work if you are using single quotes,
it does if  you use double quotes however.

So what is the huge difference and why would
i ever not need to use double quotes?

 Huh?
Logged

Of course Big Brother exists, he is the embodiment of the party..... Does he exist in the same way I exist?....... You, do not exist.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Online Online

Posts: 5139


:sniffle: Humor was so much easier before.


View Profile
« Reply #1 on: May 10, 2008, 11:19:40 AM »

single quotes are static strings and are compiled into the code as is... so particularly if you're using something like APC and you have a lot of strings, it's faster. If you don't need to do any processing on the string, that's the best way to go.

Double quotes processes the string, dereferencing any variables and controls (like \r\n etc) so there is more overhead if you're doing a lot of them.

In most cases, it probably doesn't matter much, although I'm always about that because it tells ME that I am doing processing a string very quickly, and I'm an efficiency nut.
Logged

If I can't be Mr. Root then I don't want to play.
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!