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

Related Questions

I have created below bat file to run my RMI server @echo Off set
I have the function below that copies a file in a directory and recreate
I have an XML file containing seed data that I'm trying to load into
i want to create a CLR function, i created a normal class library file
I have created a custom class (the .as is below:). It exists throughout my
I have a function to create a pdf which should return bitarray. Below is
I have the below configuration where I'm trying to create a test C function
//I have created below snippet to let the sensor to be detected. -(void)addProximitySensorControl {
I have created button 2 below: <input id=Button1 type=button value=Stop onclick=alert('hello world');/> <input id=Button2
I have created two imageViews promatically as shown below: public void createImageViews(Integer count){ ImageView[]

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.