diğer sınıflardan PHP sihirli sabitler kullanmak nasıl?

0 Cevap php


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__;
       }
    }
 }

şimdi ben başka bir sayfadan index.php, i inculded burada info.php bu yöntemi çağırın

Bu dosyada i POST dizi ayıklamak istiyorum, bu yüzden aşağıdaki kodu yazmak

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

Her şey iyi çalışıyor ama yöntem ve HATTI altında görünür

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

ama görüntülemek için wantbelow

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

bu yüzden nasıl i $more=TRUE koyarsanız watch() daha sonra yöntem ve satır numarası denir sınıfından diaply gerektiğini do.

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)

0 Cevap