Problem to read parameter #91
Replies: 4 comments
-
I believe you need to use a single arrow instead of a double arrow like so: echo $ap->system-stats->cpu . PHP_EOL; |
Beta Was this translation helpful? Give feedback.
-
I'm sorry the double arrow is from another test. I correct it to echo $ap->system-stats->cpu . PHP_EOL; and now the error is: PHP Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR), expecting ';' or ',' in |
Beta Was this translation helpful? Give feedback.
-
Ah OK. Then the issue is caused by the property name which contains a dash. Change the line to this: echo $ap->{"system-stats"}->cpu . PHP_EOL; |
Beta Was this translation helpful? Give feedback.
-
That's was it. Thank you. |
Beta Was this translation helpful? Give feedback.
-
Hi,
i have a problem to read system-stats with php.
May be it is a problem of line in system-stats, normally the names has underline?
Code:
echo $ap->system-stats=>cpu . PHP_EOL;
Error:
PHP Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW), expecting ';' or ',' in ....
"system-stats": {
"cpu": "10.9",
"mem": "40.9",
"uptime": "28187"
},
Beta Was this translation helpful? Give feedback.
All reactions