Results 1 to 1 of 1

Thread: Weird Plugin Activation Problem Due To Unexpected Characters

  1. #1
    Andy101's Avatar
    Andy101 is offline Code Otaku
    Join Date
    Aug 2009
    Location
    Kanazawa
    Posts
    1,252
    Thanks
    173
    Thanked 303 Times in 230 Posts

    Weird Plugin Activation Problem Due To Unexpected Characters

    I was getting the message that unexpected characters were output by my plugin and for the life of me I couldn't work out what I was doing wrong.

    Normally this is due to error messages due to coding problems that are not seen by the user since they are hidden by WP as it redirects the page.

    Another reason may be space characters outside of the PHP code tags, but I had none of this.

    I even tried this code for my plugin:
    PHP Code:
    <?php ?>
    i.e. nothing but the PHP tags, and still I got a warning that 3 unexpected characters were output.

    Finally, in desperation I wrote a test script to examine the mysterious characters (this was based on the actual WP code that produces this error):

    PHP Code:
    <pre>
    <?php
    ob_start
    ();
    require_once( 
    'wp-load.php' );

    if ( 
    ob_get_length() > ) {
                
    $output ob_get_clean();
                
    file_put_contents('buffer.txt'$output);
                
    $len strlen($output);
                
    printf('%x%x%x'ord($output[0]), ord($output[1]), ord($output[2]));
                die(
    "\nunexpected_output:$output:$len:");
    }
    ob_end_clean();

    die(
    "done");
    ?>
    (this script can be saved as say test.php to the root of your blog)

    This revealed that there were in fact 3 invisible characters. To cut a long story short, they were caused by me having my code editor set to produce text in UTF-8 encoding format. So there is some preceding code to identify the format causing this problem. Simply saving the plugin code file as ANSI format solved the issue. Also, it seems to work OK if you save in the UTF-8 without BOM encoding format.

    So there you go ...

  2. Thanked by:

    Aquarezz (30 October, 2010), Aziz (29 October, 2010), Will.Spencer (29 October, 2010)

Similar Threads

  1. Where Can I Get These Pictures/Characters?
    By rome9t9 in forum Building
    Replies: 0
    Last Post: 16 December, 2010, 16:57 PM
  2. Weird XHTML(?) problem... Need Help.
    By Oberon in forum Programming
    Replies: 3
    Last Post: 6 April, 2010, 12:26 PM
  3. [WTB] VCC for Adwords activation
    By Newbie191 in forum Marketplace
    Replies: 4
    Last Post: 27 March, 2010, 22:09 PM
  4. [WTS] 12 Years Old Unique Characters Domain For Sale
    By IwebSeo in forum Domains
    Replies: 14
    Last Post: 1 November, 2009, 11:30 AM
  5. Weird Problem With Subscribe2 Plugin
    By kentuckyslone in forum Wordpress
    Replies: 4
    Last Post: 21 June, 2009, 14:55 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •