WordPress.org

Ready to get started?Download WordPress

Forums

Debug Bar
$this is determined as an undefined variable (1 post)

  1. Marius Jensen (Clorith)
    Member
    Posted 1 year ago #

    The debug bar determines $this as an undefined variable when used within a class\function call, but will happily accept &$this without any notices.

    Example:

    class test_class {
      function make_menu() {
        $page_title = __( 'Page title' );
        $menu_title = __( 'Menu title' );
        $capability = 'read';
        $menu_slog  = 'test-slug';
        $function   = array( $this, 'menu_function );
    
        add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function );
      }
    
      function menu_function() {
      }
    }

    The above will create a Notice that "this" isn't defined, but replace $this with &$this and it will no longer produce this notification.

    http://wordpress.org/extend/plugins/debug-bar/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

  • RSS feed for this topic
  • Started 1 year ago by Marius Jensen (Clorith)
  • This topic is not resolved
  • WordPress version: 3.5.1

Tags

No tags yet.