NameSilo

Javascript_escape_string (PHP)

SpaceshipSpaceship
Watch

jeka911

Established Member
Impact
0
Escapes string, so it can be used inside javascript:

<?
function javascript_escape_string($str)
{
$str = str_replace(array('\\', "'"), array("\\\\", "\\'"), $str);
$str = preg_replace('#([\x00-\x1F])#e', '"\x" . sprintf("%02x", ord("\1"))',$str);
return $str;
}
?>

example:

<script language="javascript" type="text/javascript">
<!--
document.write('<? echo javascript_escape_string($str); ?>');

// -->
</script>
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable Domains — AI StorefrontUnstoppable Domains — AI Storefront
CatchedCatched

We're social

Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back