JsExpression
API reference › yii › web › JsExpression
JsExpression marks a string as a JavaScript expression.
When using Json::encode() or Json::htmlEncode() to encode a value, JsExpression objects
will be specially handled and encoded as a JavaScript expression instead of a string.
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$expression | string | The JavaScript expression represented by this object Default: null. | JsExpression |
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | Constructor. | JsExpression |
__call() | Calls the named method which is not a class method. | yii\ |
__get() | Returns the value of an object property. | yii\ |
__isset() | Checks if a property is set, i.e. defined and not null. | yii\ |
__set() | Sets value of an object property. | yii\ |
__toString() | The PHP magic function converting an object into a string. | JsExpression |
__unset() | Sets an object property to null. | yii\ |
canGetProperty() | Returns a value indicating whether a property can be read. | yii\ |
canSetProperty() | Returns a value indicating whether a property can be set. | yii\ |
className() static | Returns the fully qualified name of this class. | yii\ |
hasMethod() | Returns a value indicating whether a method is defined. | yii\ |
hasProperty() | Returns a value indicating whether a property is defined. | yii\ |
init() | Initializes the object. | yii\ |
Method details
Section titled “Method details”__construct()
Section titled “__construct() ”public function __construct(string $expression, array $config = [])Constructor.
Parameters
| Parameter | Type | Description |
|---|---|---|
$expression | string | The JavaScript expression represented by this object |
$config | array | Additional configurations for this object |
__toString()
Section titled “__toString() ”public function __toString(): stringThe PHP magic function converting an object into a string.
Returns
string: The JavaScript expression.