-2

I use Wordpress and my plugin generated 11 characters of unexpected display during the activation but i don't know why. I'm I trying to activate the plugin and to generate the table on Workbench.

<?php 
    if(!class_exists('Test')){
        $inst_test = new Test();
    }
    if(isset($inst_test)){
         register_activation_hook(__FILE__, array($inst_test, 'test_install'));
    }    
    class Test {
        function test_install(){
            global $wpdb;
            $table_site = $wpdb->prefix.'test';

            if($wpdb->get_var("SHOW TABLES LIKE '$table_site'") != $table_site) {
                $sql = "CREATE TABLE `$table_site'(
                    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
                    `nom` VARCHAR(255) NOT NULL,
                    `title` VARCHAR(255) NOT NULL,
                    `subtitle` VARCHAR(255) NOT NULL
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
            require_once(ABSPATH.'wp-admin/includes/upgrade.php');
            dbDelta($sql);
            }
        }
    }?>
Nedjim DN
  • 543
  • 2
  • 6
  • 12
  • 2
    Could be whitespace after the closing `?>` ... the general recommendation is to _not_ use that at the very end of script files (it is optional in that place.) Try without it, and see if that changes anything. – CBroe May 18 '17 at 09:23
  • You resolved my problems. Actually, I was concentrated on spaces inside my php's beacons. Thank's! – Nedjim DN May 18 '17 at 09:30
  • ?¿ https://i.stack.imgur.com/tFBY0.jpg ?¿ – brasofilo May 18 '17 at 14:11
  • @brasofilo Thank you for your answer but I had already seen these comments otherwise I would not have asked my question – Nedjim DN May 19 '17 at 12:41

1 Answers1

0

Issues likes this are often due to whitespace after the closing ?>

The general recommendation is to not use that at the very end of script files - it is optional in that place, and leaving it out helps avoiding problems like this.

CBroe
  • 91,630
  • 14
  • 92
  • 150