Package | system.web.helpers |
---|---|
Inheritance | class CJavaScriptExpression |
Since | 1.1.11 |
Source Code | framework/web/helpers/CJavaScriptExpression.php |
Property | Type | Description | Defined By |
---|---|---|---|
code | string | the javascript expression wrapped by this object | CJavaScriptExpression |
Method | Description | Defined By |
---|---|---|
__construct() | CJavaScriptExpression | |
__toString() | String magic method | CJavaScriptExpression |
the javascript expression wrapped by this object
public void __construct(string $code)
| ||
$code | string | a javascript expression that is to be wrapped by this object |
public function __construct($code)
{
if(!is_string($code))
throw new CException('Value passed to CJavaScriptExpression should be a string.');
if(strpos($code, 'js:')===0)
$code=substr($code,3);
$this->code=$code;
}
public string __toString()
| ||
{return} | string | the javascript expression wrapped by this object |
public function __toString()
{
return $this->code;
}
String magic method
sample usage
$jsObj = new CJavaScriptExpression('console.log("please check yo log!")');
echo $jsObj;
another sample usage
$jsObj = new CJavaScriptExpression('alert("hey")'); echo CHtml::script($jsObj);
Signup or Login in order to comment.