Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
233 views
in Technique[技术] by (71.8m points)

php - Special characters in property name of object

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.

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
echo $myobject->{'%myproperty'};

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...