I need to create JSON with php with this content
{
"@context":"something",
"type":"something"
}
So I created class
class doc
{
public $context;
public $type;
}
which gives me JSON without @ sign
{
"context":"something",
"type":"something"
}
If I add @ in php, I get syntax error. Is it possible that I could use @ as a part of variable name, or how can I do it?
class doc
{
public $@context; //this is a problem
public $type;
}
I need to have object that should be inserted into MongoDB at the end