Arquivos
hhvm/hphp/test/slow/array_object/setFlags.php
T
Paul Tarjan cef8fcc6e3 add ArrayObject
This is a pure PHP implementation of ArrayObject. It does't match the reference semantics of zend's implementation, but it is much easier to build this in pure PHP, so its a good first step. It is better to have it like this, than to not have it at all.
2013-05-24 09:48:22 -07:00

18 linhas
426 B
PHP

<?php
// Array of available fruits
$fruits = array(
"lemons" => 1,
"oranges" => 4,
"bananas" => 5,
"apples" => 10
);
$fruitsArrayObject = new ArrayObject($fruits);
// Try to use array key as property
var_dump($fruitsArrayObject->lemons);
// Set the flag so that the array keys can be used as properties
$fruitsArrayObject->setFlags(ArrayObject::ARRAY_AS_PROPS);
// Try it again
var_dump($fruitsArrayObject->lemons);