/    Sign up×
Community /Pin to ProfileBookmark

ermm ‘ over "

Ok, so I heard that you only use ” when theres a variable involved, because it takes up time… other wise use ‘.. right? well.. what if you have n?.. THe ‘ doesn’t work with n.. so should I use ” or say ‘this text.. + new line ‘ . “n”; hm? This is probably a dumb question, but up until now, I thought I knew php pretty well, but it turns out theres much for me to learn, so thats why I’m asking.. I’m expecting that it wold be easier to use ” because then it doesn’t compute two different things..

hehe thanks..
Kyle

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMar 27.2006 — The time difference - if any - is so minimal that I wouldn't worry about it unless I were programming a mission-critical realtime system. And if I were doing that, I wouldn't be using PHP. (You're probably talking savings of a few milliseconds or even just microseconds, depending on the server where your code is running).

Probably of much more importance 99.99% or so of the time is to keep your code as easy to read as possible [i]by you[/i], so that you can make changes at some later time with a minimum of agony.
Copy linkTweet thisAlerts:
@Kyleva2204authorMar 27.2006 — Hm- i was just reading some things online, and they are like ommeeegod save time!! >_<!!!! so yeah- just questioning it! ?
Copy linkTweet thisAlerts:
@NogDogMar 27.2006 — Try this little test, and refresh the page a few times (to account for random variations in processing time):
[code=php]
<?php
function microtime_float()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
$time0 = microtime_float(); // "prime the pump"
$time1 = microtime_float();
echo '<p>This is a test.';
echo 'It is only a test.';
echo 'This is the end of the test</p>';
$time2 = microtime_float();
echo "<p>This is a test.";
echo "It is only a test.";
echo "This is the end of the test</p>";
$time3 = microtime_float();
echo <<<EOD
<p>This is a test.
It is only a test.
This is the end of the test</p>
EOD;
$time4 = microtime_float();
echo sprintf("<p>Test 1 took %f seconds</p>", $time2 - $time1);
echo sprintf("<p>Test 2 took %f seconds</p>", $time3 - $time2);
echo sprintf("<p>Test 3 took %f seconds</p>", $time4 - $time3);
?>
[/code]

Typical output on my PC was:

Test 1 took 0.000050 seconds

Test 2 took 0.000049 seconds

Test 3 took 0.000056 seconds
[/quote]

Hardly worth much worry about which is faster, I think?
Copy linkTweet thisAlerts:
@SpectreReturnsMar 28.2006 — I used to use ' but then I started C++ and C# and what not, so now I use " but don't use the variable parsing ability. (sorry, it seemed relevant when I typed it)
×

Success!

Help @Kyleva2204 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...