Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1021865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:22:33+00:00 2026-05-16T11:22:33+00:00

i have created below function in a file info.php to debug variable & data

  • 0

i have created below function in a file info.php to debug variable & data during page load

 class Info {
    static function watch($what,$msg='',$more=FALSE)
    {
        echo "<hr/>";
        echo "<br/>".$msg.":";
        if( is_array($what) || is_object($what) )
        {
            echo "<pre>";
            print_r($what);
            echo "</pre>";
        }
        else{
                echo $what;
        }
       if($more) 
       {
            echo "<br/>METHOD:".__METHOD__;
            echo "<br/>LINE:".__LINE__;
       }
    }
 }

now i call this method from another page index.php, where i inculded info.php

in this file i want to debug POST array, so i write below code

class Testpost {
    __construct() { // some basic intializtion }
    function getPostdata($postarray) {
              $postarray=$_POST;
    Info::watch($postarray,'POST ARRAY', TRUE);
}

everything is working fine but method and LINE appears below

METHOD:Info::watch();
LINE:17 // ( where this code is written in Info class)

but i wantbelow to display

METHOD: Testpost::gtPostdata()
LINE:5( where this function is called in Testpost class)

so how do i do that if i put$more=TRUE in watch() then method and line number should be diaply from the class where it is called.

can i use self:: or parent::in watch method?? or something else
please suggest me how to call magic constants from other classes or is there any other method to debug varaibale?? ( please dont suggest to use Xdebug or any other tools)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T11:22:34+00:00Added an answer on May 16, 2026 at 11:22 am

    You have to use the debug_backtrace() php function.

    You also have below the solution to your problem. Enjoy! 🙂

     <?php
        class Info {
            static function watch($what,$msg='',$more=FALSE)
            {
                echo "<hr/>";
                echo "<br/>".$msg.":";
                if( is_array($what) || is_object($what) )
                {
                    echo "<pre>";
                    print_r($what);
                    echo "</pre>";
                }
                else{
                        echo $what;
                }
               if($more) 
               {
    
                    $backtrace = debug_backtrace();
                    if (isset($backtrace[1])) 
                    {
                        echo "<br/>METHOD:".$backtrace[1]['function'];
                        echo "<br/>LINE:".$backtrace[1]['line'];
                    }
    
               }
            }
         }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 542k
  • Answers 542k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Server Trigger You can see them here select * from… May 17, 2026 at 3:12 am
  • Editorial Team
    Editorial Team added an answer Well, to start with List<T> does have the FindAll and… May 17, 2026 at 3:12 am
  • Editorial Team
    Editorial Team added an answer If all your services implement the same contract (I mean… May 17, 2026 at 3:12 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have created a class library in VB .NET. Some code in the library
I have the following pages: page1.php, page2.php and page3.php. Code in each of them
Ok, I have an in template function that get's submitted via method=POST. But I
@Solved The two subquestions I have created have been solved (yay for splitting this
I have file test.pdf in my Application Bundle. I run test in iPhone Simulator
I have been struggeling all day to read a json file from server and
I have to create a script that takes a mySQL table, and exports it
i've created a simple panel with a title bar, and i'm trying to share
SOLVED. See below for the corrections (labeled FIXED). I'm having trouble creating a shared
I have this link that creates a few div's in which a form is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.