constants_basic_003.phpt 579 B

12345678910111213141516171819202122232425262728
  1. --TEST--
  2. Ensure class properties and constants can be defined in terms of constants that are not known at compile time.
  3. --FILE--
  4. <?php
  5. include 'constants_basic_003.inc';
  6. class B
  7. {
  8. public static $a = A::MY_CONST;
  9. public static $c = C::MY_CONST;
  10. const ca = A::MY_CONST;
  11. const cc = C::MY_CONST;
  12. }
  13. class C
  14. {
  15. const MY_CONST = "hello from C";
  16. }
  17. var_dump(B::$a);
  18. var_dump(B::$c);
  19. var_dump(B::ca);
  20. var_dump(B::cc);
  21. ?>
  22. --EXPECT--
  23. string(12) "hello from A"
  24. string(12) "hello from C"
  25. string(12) "hello from A"
  26. string(12) "hello from C"