PHP access object property through constant's value -
I have a Player class in which assets: $ Infantry, $ vehicles and $ air.
is when dealing with players, I do not know which property is being used as an array, which used the properties to use to create a random order Shuffle is done.
I try to use it, but it does not work. Strange, it does not give me an empty property error, so I think this is pointing to some property:
& lt ;? Php $ typeOrder = array (_INF_, _VEH_, _AIR_); // _INF_ const = "infantry" etc. $ turnOrder = $ typeOrder; Shuffle ($ turnOrder); {$ AttType = $ turnOrder [$ i] for ($ I = 0; $ i & lt; 3; $ i ++); Print $ p1- & gt; $ AttType; }? & Gt; How do I get into a constant with a fair value in a property?
Thank you.
It should work - as long as $ p1-> Infantry etc. What is PHP giving you exactly the error? By the way, let's look at one.
Comments
Post a Comment