title: PHP Anonymous functions: undefined variable
body: <p>I'm having these two WordPress functions:</p>
  
  <pre><code>$wpb_set_post_views = function($postID) {
      $count_key = 'wpb_post_views_count';
      $count = get_post_meta($postID, $count_key, true);
      if($count==''){
          $count = 0;
          delete_post_meta($postID, $count_key);
          add_post_meta($postID, $count_key, '0');
      }else{
          $count++;
          update_post_meta($postID, $count_key, $count);
      }
  };
  
  add_action( 'wp_head', function ($post_id) {
      if ( !is_single() ) return;
      if ( empty ( $post_id) ) {
          global $post;
          $post_id = $post-&gt;ID;
      }
      $wpb_set_post_views($post_id);
  });
  </code></pre>
  
  <p>But the page return <code>Notice: Undefined variable: wpb_set_post_views</code> for the last line.</p>