* adjust function js::set.

This commit is contained in:
wangyidong
2013-01-24 05:31:47 +00:00
parent 00f8d9392b
commit 7edea52a4e

View File

@@ -777,23 +777,27 @@ EOT;
*
* @param string $key
* @param mix $value
* @param string $type string|json|number
* @static
* @access public
* @return void
*/
static public function set($key, $value, $type = 'string')
static public function set($key, $value)
{
$js = self::start(false);
if($type == 'json')
if(is_array($value) or is_object($value))
{
$value = json_encode($value);
$js .= "$key = $value";
}
elseif($type == 'number')
elseif(is_numeric($value))
{
$js .= "$key = $value";
}
elseif(is_bool($value))
{
$value = $value ? 'true' : 'false';
$js .= "$key = $value";
}
else
{
$value = addslashes($value);