1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Why this code gives notice

Discussion in 'PHP' started by trecords, Apr 18, 2012.

  1. #1
    Hi,

    I want to clean up wordpress theme from all notices but i am getting notice on very simple staff:
    
    if (!function_exists(comment_reply)) {
    	function comment_reply() {
    		if ( is_singular() ) wp_enqueue_script( 'comment-reply' );
    	}
    }
    add_action('get_header', 'comment_reply');
    PHP:
    Notice is in first line where function_exists and it says 'comment_reply' is not defined. The purpose adding function_exists is already for to check if that function defined and it is wrong by PHP to give such notice even its purpose of current script.
    So please tell me how can i rewrite this code not to get this notice?

    Thanks.
     
    trecords, Apr 18, 2012 IP
  2. showdown

    showdown Active Member

    Messages:
    54
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    71
    #2
    Seems you've forgotten the apostrophes in function name: 'comment_reply'
     
    showdown, Apr 18, 2012 IP
  3. nik00726

    nik00726 Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hello there is small mistake

    Use quotes in function name for which you want to check. without quotes php consider as constant

    just add if (!function_exists('comment_reply')) {

    }
     
    nik00726, Apr 18, 2012 IP