This is a discussion on PHP double quotes inside double quotes within the alt.comp.lang.php forums, part of the PHP Programming Forums category; I am trying to figure out how to do double quotes inside double quotes $newcode = str_replace("<a", &...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I am trying to figure out how to do double quotes inside double quotes
$newcode = str_replace("<a", "<a target=_blank", $newcode); $newcode = str_replace("<a", "<a target="_blank"", $newcode); the code works as is in the first example...but it screws up my validation when it is parsed |
|
|||
|
MSB wrote:
> I am trying to figure out how to do double quotes inside double quotes > > $newcode = str_replace("<a", "<a target=_blank", $newcode); > > $newcode = str_replace("<a", "<a target="_blank"", $newcode); > > the code works as is in the first example...but it screws up my > validation when it is parsed You could : - quote with other quotes (so ' "bla"' will work), which I'd recommend. - escape your quotes (so " \"bla\"") - in large strigs, I'd recommend HEREDOC syntax. Grtz, -- Rik Wasmus |
|
|||
|
Hi.
MSB wrote: > I am trying to figure out how to do double quotes inside double quotes > > $newcode = str_replace("<a", "<a target=_blank", $newcode); > > $newcode = str_replace("<a", "<a target="_blank"", $newcode); Just escape with '\'. This is explained here: http://de2.php.net/types.string $newcode = str_replace("<a", "<a target=\"_blank\"", $newcode); > > the code works as is in the first example...but it screws up my validation > when it is parsed > > |
|
|||
|
"MSB" <ajhfdsa@adf.com> wrote in message news:e45ef$45381d91$d8600654$7726@ALLTEL.NET... >I am trying to figure out how to do double quotes inside double quotes > > $newcode = str_replace("<a", "<a target=_blank", $newcode); > > $newcode = str_replace("<a", "<a target="_blank"", $newcode); > > the code works as is in the first example...but it screws up my validation > when it is parsed > I bypass this problem, (and the quote character, "\"), by using single quotes. This works for me: $newcode = str_replace(' "<a", "<a target=_blank" ' , $newcode); (Note: I have put a space between the single and double quotes here ONLY for clarity for you to see what I mean. In the actual code I do not have any space. Shelly |
![]() |
| Thread Tools | |
| Display Modes | |
|
|