Skip to content

Instantly share code, notes, and snippets.

@mitaken
Created November 5, 2013 14:02
Show Gist options
  • Select an option

  • Save mitaken/7319430 to your computer and use it in GitHub Desktop.

Select an option

Save mitaken/7319430 to your computer and use it in GitHub Desktop.
stdClassのPropertyはReflectionClassで取得できない?
<?php
$class = new \stdClass;
$class->key1 = 'value1';
$class->key2 = 'value2';
$class->key3 = 'value3';
$reflection = new \ReflectionClass($class);
$properties = $reflection->getProperties();
foreach ($properties as $property) {
echo "{$property->getName()}: {$property->getValue()}\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment