php - Special characters in property name of object
Get the solution ↓↓↓If I have an object that contains a property that starts with a % symbol, how can I get its value.
If I use
echo $myobject->%myproperty;
I get an error
Parse error: syntax error, unexpected '%', expecting T_STRING or T_VARIABLE
I know I shouldn't use % in variable names, but it wasn't my doing and I'm stuck with it.
Answer
Solution:
I have one more solution to convert object to an array, so that you will not get an error.
I have a symbol - on the object index, so I have used the above solution and got success.
$array = (array) $yourObject;
Reference: http://www.php.net/manual/en/language.types.array.php
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: use the option --with-all-dependencies (-w) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.