Literal JSON data
Posted by SvenMichaelKlose 3 years ago
Use double backticks \`\` to start and end a literal JSON expression as if it was inside a double-quoted string. It could be calling json\_encode() but one could take the advantage to let the parser transform it into fast and cache-able regular 'code'.
``` php
sendRequest (``{
"id": $eventID,
"one_of": [1, 2, 4]
}``);
// would effectively become:
sendRequest ((object) [
"id" => $eventID,
"one_of" => [1, 2, 4]
]);
```