Re: need help on coding

From: Date: Sun, 15 Jun 2003 17:37:37 +0000
Subject: Re: need help on coding
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-151596@lists.php.net to get a copy of this message
"Shien Hang Low" <shienhang@hotmail.com> wrote in message news:Law8-F80EF0HG0anlzm00029a6c@hotmail.com... > > >problem : > > > >code : > ><? > >$data= "message"; > >echo $data; > >?> > > > >output : > >message > >----------------------------------- > >if i want the output to be : > >"message" > > > >i try to used the below code but fail: > ><? > >$data = ""message""; > >echo $data; > >?> > > > >so i wonder if i want to get the output that with the > >'quatation' mark how can i do it, your help means alot to me > >thank you for your time and patient . There are two ways of doing this: First, you could use a literal string (using single- quote marks ie ' ) $data = ' "message" '; Secondly, you could escape the quotation marks inside the string, ie $data = " \"message\" "; I find the first method is a little easier to read; however, single-quoted strings are not evaluated for variable substitution, ie $insert = 'test'; // $data = ' "$insert" '; // will not work! $data = ' "' . $insert . '" '; $data = " \"$insert\" "; Hope this helps. -- Hugh Bothwell hugh_bothwell@hotmail.com Kingston ON Canada v3.1 GCS/E/AT d- s+: a- C+++ L++>+++$ P+ E- W+++$ N++ K? w++ M PS+ PE++ Y+ PGP+ t-- 5++ !X R+ tv b++++ DI+++ D-(++) G+ e(++) h-- r- y+

« previous php.general (#151596) next »