Jump to content

Single quote/double quote issue


dcaplan

Recommended Posts

I am using an ajax/php live search on my site combined with the greybox javascript. The problem I am having is that when trying to call the javascript from my ajax/php live search, i cannot get it to work because it requires a double quote.

 

Here is what I am trying to get it to look like:

 

      if ($hint=="")

        {

        $hint="<a href='" .

        $z->item(0)->childNodes->item(0)->nodeValue .

        "' target='_blank' rel="gb_page_center[640, 480]">" .

        $y->item(0)->childNodes->item(0)->nodeValue . "</a>";

        }

 

But of course, the only way I can not break my search is if I change the double quote to a single and than my 'rel' stops working.

 

Any suggestions?

Link to comment
https://forums.phpfreaks.com/topic/204566-single-quotedouble-quote-issue/
Share on other sites

Use the backslash to escape the double quote:

<?php
if ($hint=="")
        {
        $hint="<a href='" . 
        $z->item(0)->childNodes->item(0)->nodeValue . 
        "' target='_blank' rel=\"gb_page_center[640, 480]\">" . 
        $y->item(0)->childNodes->item(0)->nodeValue . "</a>";
        }
?>

You could also use single quotes in this case:

<?php
if ($hint=="")
        {
        $hint="<a href='" . 
        $z->item(0)->childNodes->item(0)->nodeValue . 
        "' target='_blank' rel='gb_page_center[640, 480]'>" . 
        $y->item(0)->childNodes->item(0)->nodeValue . "</a>";
        }
?>

 

Ken

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.