Feed the to-be-escaped variable to escape_js_var

So it won't return an empty string anymore. The signature of
escape_js_var is:
 mixed str_replace  ( mixed $search  , mixed $replace  , mixed $subject [, int &$count  ] )
So we have to give at least three parameters. I wonder why it doesn't
complain right now...
This commit is contained in:
Tobias Mueller 2009-06-06 16:12:53 +02:00
parent f3b14cd472
commit b2727e6e9b

View file

@ -108,9 +108,9 @@ cursor: pointer;
<?php <?php
function escape_js_var($var) { function escape_js_var($var) {
$var = preg_replace("([\\\'\"\/])", "\\$1"); $var = preg_replace("([\\\'\"\/])", "\\$1", $var);
$var = str_replace("\n", "\\n"); $var = str_replace("\n", "\\n", $var);
$var = str_replace("\r", "\\r"); $var = str_replace("\r", "\\r", $var);
return $var; return $var;
} }