Zend Framework
3.0
|
Encode a string to a native JavaScript expression. More...
Public Member Functions | |
__construct ($expression) | |
__toString () | |
Cast to string. | |
Protected Attributes | |
$expression | |
Encode a string to a native JavaScript expression.
This class simply holds a string with a native JavaScript expression, so objects or arrays to be encoded with Zend can contain native JavaScript expressions.
Example:
$foo = array( 'integer' => 9, 'string' => 'test string', 'function' => Zend( 'function () { window.alert("javascript function encoded by Zend\Json\Json") }' ), );
echo Zend::encode($foo, false, ['enableJsonExprFinder' => true]);
The above returns the following JSON (formatted for readability):
{ "integer": 9, "string": "test string", "function": function () {window.alert("javascript function encoded by Zend\Json\Json")} }
__construct | ( | $expression | ) |
string | $expression | The expression to represent. |
__toString | ( | ) |
Cast to string.
|
protected |