Access( or declare) an object member with an illegal character in PHP -
i'm working personal weather station upload protocol on weather underground. creating class attributes pws may contain, , use http_build_query() create request.
my problem is: weather underground has 2 fields invalid identifiers names php. check out:
aquv-aeth -uv-aeth (second channel of aethalometer @ 370 nm) ug/m3 aqpm2.5 - pm2.5 mass - ug/m3
my class can not contain these property names, can do?
erro:
class foo { public aquv-aeth = null; public aqpm2.5 = null; }
php supports dynamically added properties object,so:
class foo{ } $foo = new foo(); $foo->{'aquv-aeth'} = 'data1'; // add , init new porperty object $foo->{'aqpm2.5'} = 'data2'; echo $foo->{'aquv-aeth'}; // access special porperty name $obj->{'name'}
Comments
Post a Comment