php function for checking the variable description ????

Discussion in 'PHP' started by claystudio@cbn.net.id, Feb 16, 2009.

  1. #1
    hi, i'm php newbie, usually the big script is broke down into smaller file to make them more easy to debug and making a good structure. Now in my case:
    1. i create a lot of functions saved in many different file, then within the main php file i use include to call the function. I have a variable , let's call it $finalresult, which is an instance of a class/obj , where this class is also an instance of another class, and so on.... . So sometime after instancing in many level, i forgot the structure of this $final variable. so i have to go back open the reference class one by one until i got the master class. If i have to do it over and over again , it will need a lot of time. so my question.. is there any other faster way to do it? for example .. is there any php function that can show the structure of the variable in detail??

    2. is there any php script editor software where i can do something like inserting the breakpoint , so i can run and debug easily. or where i can run the script line by line, so i can watch the changes of my variable in realtime. is it possible? is there such program?? sorry for the stupid question :D


    thanx
    andi
     
    claystudio@cbn.net.id, Feb 16, 2009 IP
  2. Colbyt

    Colbyt Notable Member

    Messages:
    3,224
    Likes Received:
    185
    Best Answers:
    0
    Trophy Points:
    210
    #2
    I don't know if this comment will help you or not.

    I usually build in a series of echo statements and tag them //debug so that I can see what is going on when something is running. Example echo "$_POST[some value]"; //debug only

    I also build in breakpoints as in exit; //debug only

    I am not aware of any scripted solution.
     
    Colbyt, Feb 16, 2009 IP
  3. spyka

    spyka Greenhorn

    Messages:
    90
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #3
    I'm not too sure what you mean in your first question but I have you looked at functions like get_parent_class and http://www.php.net/manual/en/function.get-object-vars.php]get_object_vars - they may be of help for what you want to do. Also (as of PHP5) you can use foreach to iterate through class variables.

    In regards to debugging I am not aware of breakpoint system in PHP, try just printing/echoing your variables at the different stages in your program of making use of print_r for arrays and such. hope that helsp
     
    spyka, Feb 16, 2009 IP