• Hi
    I’ve turn on WP_DEBUG in wp-config.php:

    //define('WP_DEBUG', false);
    
    define('WP_DEBUG', true);
    define('WP_DEBUG_LOG', true);
    define('WP_DEBUG_DISPLAY', false);
    ini_set('display_errors', 0);
    

    I want to get a warn in cases like this:

    
     $qry=new WP_Query([
                     'posttye'  => 'post',
                     'category_name' => 'featured'
                 ]);
                ?>
    
                       <?php if (have_posts()):?>
                          <?php while($qry->have_posts()):$qry->the_post();?>
                              <?php  echo  $qry->current_post();?>
                          <?php endwhile;?>
                      <?php endif;?>
    

    the problem is there : $qry->current_post(),current_post is not method is just a field,correct
    is : $qry->current_post

    in case of incorrect syntax it is echo empty string,I want a warning/error

    I’ve tested a php script

    
    
    class myClass{
     var $field1="value 1";
      function Method1(){
          echo("field1 is :".$this->field1()); 
         // correct is  echo("field1 is :".$this->field1); 
      }
     
     }
    
    $obj=new myClass();
    $obj->Method1();
    

    and I got
    Fatal error: Uncaught Error: Call to undefined method myClass::field1() in index.php on line 6
    ( ! ) Error: Call to undefined method myClass::field1() in index.php on line 6

    how to have this in WP too
    thanks!

    • This topic was modified 8 years, 4 months ago by mrapi.
    • This topic was modified 8 years, 4 months ago by mrapi.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    Hi there!

    The example you have using myClass is correct in that you should be getting a fatal error. There is no method field defined in the class. You can usually tell when it is a method by the () at the end.

    Generally the code looks like:

    
    class Fox_Show {
    
        // this is a property
        public $var = 'Lana';
    
        // This is a method
        function yell() {
            echo $this->var; 
        }
    }
    
    $archer = new Fox_show();
    $archer->yell();
    

    Does that help you understand a little?

    Thread Starter mrapi

    (@mrapi)

    Hi,thanks for the answer
    my problem is not to understand what is wrong,I want WordPress to notify me by a error message in case of using a filed name like a method,just like a simple PHP script does
    thanks

    Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    It almost sounds like a plugin is disabling that. O_o

    Is there anything in the debug.log file?

    Are you using any plugins like debug bar or query monitor?

    Thread Starter mrapi

    (@mrapi)

    Hi,no plugin for debug/monitor
    in debug.log writes only fatal errors like this
    <?php echo($qry->current_post(')==0 ? 'active':''); ?>

    error there: current_post(‘)
    thanks.

    • This reply was modified 8 years, 4 months ago by mrapi.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘WP_DEBUG=true but no message is shown’ is closed to new replies.