Handling properties of an object that have problem characters like colons for example

If a property has a colon in it or another offending character, wrap the property in {" and "}. See example below.

<?php
$myobj = (object) array("property1" => "value1", "property:two" => "value2");

var_dump($myobj);

print($myobj->property1);

print("\n\n");

print($myobj->{"property:two"});
?>

Page Comments (Click to edit)






[Click to add or edit comments])

Please prepend comments below including a date

Design by N.Design Studio, adapted by solidGone.org (version 1.0.0)
Have a nice day.