property_exists.phpt 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. --TEST--
  2. Testing property_exists()
  3. --FILE--
  4. <?php
  5. class aParent {
  6. public static function staticTest() {
  7. $a = new A;
  8. var_dump(property_exists($a, "prot"));
  9. var_dump(property_exists($a, "prot2"));
  10. var_dump(property_exists($a, "prot3"));
  11. print "------------------\n";
  12. var_dump(property_exists("A", "prot"));
  13. var_dump(property_exists("A", "prot2"));
  14. var_dump(property_exists("A", "prot3"));
  15. print "------------------\n";
  16. }
  17. public function nonstaticTest() {
  18. $a = new A;
  19. var_dump(property_exists($a, "prot"));
  20. var_dump(property_exists($a, "prot2"));
  21. var_dump(property_exists($a, "prot3"));
  22. print "------------------\n";
  23. var_dump(property_exists("A", "prot"));
  24. var_dump(property_exists("A", "prot2"));
  25. var_dump(property_exists("A", "prot3"));
  26. }
  27. }
  28. class A extends aParent {
  29. static public $prot = "prot";
  30. static protected $prot2 = "prot";
  31. static private $prot3 = "prot";
  32. }
  33. A::staticTest();
  34. $a = new a;
  35. $a->nonstaticTest();
  36. ?>
  37. --EXPECT--
  38. bool(true)
  39. bool(true)
  40. bool(true)
  41. ------------------
  42. bool(true)
  43. bool(true)
  44. bool(true)
  45. ------------------
  46. bool(true)
  47. bool(true)
  48. bool(true)
  49. ------------------
  50. bool(true)
  51. bool(true)
  52. bool(true)