p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: Difference between ' ' and " "


Message #1 by "Fernando Sotano Camilo" <fcamilo@u...> on Tue, 29 Oct 2002 19:23:20
What is the difference between " " and ' ' in commands like

exec('command',$out);
exec("command",$out);

??????????????

Thanks.
Fernando.
Message #2 by "Nikolai Devereaux" <yomama@u...> on Tue, 29 Oct 2002 11:17:00 -0800
nothing.  Read the manual about the different string delimiters, it has more
information than anyone here is likely to give you.

http://www.php.net/types.string


take care,

nik

Message #3 by "David Scott-Bigsby" <DScott-Bigsby@P...> on Tue, 29 Oct 2002 11:18:24 -0800
> What is the difference between " " and ' ' in commands like
>
> exec('command',$out);
> exec("command",$out);

No difference in this example, as both contain a literal value.

The difference is that in a "" string, PHP parses it for variables and 
coverts them to their value. This doesn't happen with ''. (PHP also 
converts escaped characters, e.g., "\n", in double quoted strings.)

So...

$world =3D 'Earth';
echo ('Hello $world\n');  // gives you: Hello $world\n
echo ("Hello $world\n");  // gives you: Hello Earth<newline>

dsb

***************************************       
David Scott-Bigsby
Product Manager, Web Site and PEDN

PureEdge Solutions
The Leader in Secure XML e-Forms

v:250-708-8145  f:250-708-8010
1-888-517-2675   www.PureEdge.com
***************************************
Message #4 by "Gerry Vandermaesen" <gerry@a...> on Tue, 29 Oct 2002 20:23:22 +0100
Double-quotes will be evaluated for variables and escape sequences,
whereas single-quotes are literal. For example:

$str = 'world';
echo("Hello $str"); // returns 'Hello world'
echo('Hello $str'); // return 'Hello $str'

There is more to it however, see
http://www.php.net/manual/en/language.types.string.php

Gerry.


-----Original Message-----
From: Fernando Sotano Camilo [mailto:fcamilo@u...] 
Sent: dinsdag 29 oktober 2002 19:23
To: beginning php
Subject: [beginning_php] Difference between ' ' and " "


What is the difference between " " and ' ' in commands like

exec('command',$out);
exec("command",$out);

??????????????

Thanks.
Fernando.


  Return to Index