dereferencing_001.phpt 547 B

1234567891011121314151617181920212223242526272829303132333435
  1. --TEST--
  2. ZE2 dereferencing of objects from methods
  3. --SKIPIF--
  4. <?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed'); ?>
  5. --FILE--
  6. <?php
  7. class Name {
  8. function Name($_name) {
  9. $this->name = $_name;
  10. }
  11. function display() {
  12. echo $this->name . "\n";
  13. }
  14. }
  15. class Person {
  16. private $name;
  17. function person($_name, $_address) {
  18. $this->name = new Name($_name);
  19. }
  20. function getName() {
  21. return $this->name;
  22. }
  23. }
  24. $person = new Person("John", "New York");
  25. $person->getName()->display();
  26. ?>
  27. --EXPECT--
  28. John