Jump to content

Escaping ampersands?


woolyg

Recommended Posts

Hi all,

 

I have a piece of code in a file called sajax.php:

 

if(!A && typeof XMLHttpRequest != "undefined")

 

It all works fine, but when I go about debugging and attempting to make the page XHTML-compliant, the '&&' bit gets caught out.

If I replace them with & in each case, the PHP document ceases to function, so I have to revert back to '&&' to get it going again.

 

I have added the following to my php.ini file on the server:

 

arg_separator.output  = "&"

arg_separator.input    = "&"

 

..but it makes no difference.

 

Is there a different way of escaping ampersands so the XHTML inspector will allow them, and for my AJAX to still work?

 

All help much appreciated.

WoolyG

Link to comment
https://forums.phpfreaks.com/topic/81571-escaping-ampersands/
Share on other sites

  • 2 weeks later...

<script language="JavaScript" type="text/javascript">
/*<![CDATA[*/

/*]]>*/
</script>

 

is the syntax for the CDATA...

 

also you might try separating your javaScript and HTML by putting your javascript in an external file and referencing it :

 


<script type="text/javascript" src="external_javascript_file_name.js"></script>

 

 

Jos.

Link to comment
https://forums.phpfreaks.com/topic/81571-escaping-ampersands/#findComment-424367
Share on other sites

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.