Web Analytics Made Easy -
StatCounter PHP Classes - CodingForum

Announcement

Collapse
No announcement yet.

PHP Classes

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PHP Classes

    Hi guys,

    I remember seeing ages ago a method that would print the contents of a class to the screen with the field names and there current values. Or it could have been for arrays not sure tho. Does anyone know what it is?

  • #2
    I don't know anything for classes, but you may of been thinking of print_r() for arrays.

    Comment


    • #3
      I think that was it, probably arrays i was think of

      Comment


      • #4
        var_dump() prints object properties as array indexes.
        I'm not sure if this was any help, but I hope it didn't make you stupider.

        Experience is something you get just after you really need it.
        PHP Installation Guide Feedback welcome.

        Comment


        • #5
          Couple other handy functions. But they wont allow you to access "current var values".

          PHP Code:
          $obj = new obj();

          print_r(get_class_methods($obj));
          print_r(get_class_properties($obj)); 
          Active PHP/MySQL application developer available for immediate work.
          syosoft.com mavieo.com - Remote Web Site Administration Suite - Reseller Ready

          Comment


          • #6
            I don't believe var_dump will print out PHP 5 properties for private members. I'm still learning PHP 5 and the new object model (though so far I love it!) so I've not actually tried it, but if you're working with PHP 5 then I think the correct way would be to implement a __toString() method in your class.

            Comment


            • #7
              ... believe it or not but it will...
              I'm not sure if this was any help, but I hope it didn't make you stupider.

              Experience is something you get just after you really need it.
              PHP Installation Guide Feedback welcome.

              Comment


              • #8
                I only wanted this to look inside a class when an error occurs and record in an error log. I have decided to use the Exception class and just print a stack trace into my log. But on my travels i came across this. It appears to do exactly what i was after in the first place.

                Comment

                Working...
                X