curl-and-php
Re: Quotes: Single, double, and NONE
Date: Sat, 27 Oct 2007 08:40:29 -0700
People:
Back to PHP basics: PHP is flawed but not *THAT* flawed.
(apologies to most of you who know this) here is how it rolls.
Double quotes and single treat embedded variables differently.
"foo" and 'foo' happen to be the same because
there is no variable in it. For this reason single quotes are more
efficient.
However if $a == 1 then "foo$a" evaluates to foo1 and 'foo$a' is just
foo$a
In the case of curl declarations, CONSTANTS like CURLOPT_PUT are
arbitrary constants defined in the curl module and substituted
textually. Someone may be passing actual arg strings such as post
var strings that have no embedded variables and getting away with not
knowing the difference between single and double, but for constants that
will not fly. You DON'T quote them at all single or double.
The constant strings are used
both for human legibility and maintainability of the module. Normally we
don't care what it is.
You can test if you print CURLOPT_PUT; and print "CURLOPT_PUT";
there will be a difference.
On Sat, 2007-10-27 at 15:31 +0200, Daniel Stenberg wrote:
> On Sat, 27 Oct 2007, simon_at_ice.org wrote:
>
> > I can attest using single or double quotes in curl declarations in PHP make
> > no difference.
>
> So are you saying that in PHP land the following two lines are identical?
>
> curl_setopt($c, "CURLOPT_PUT", "TRUE");
>
> curl_setopt($c, CURLOPT_PUT, TRUE);
>
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2007-10-27