我正在开发WordPress插件并在激活时遇到此错误:
错误:插件在激活期间生成了4个意外输出字符。如果您发现“已发送标头”消息,联合供稿问题或其他问题,请尝试停用或删除此插件。
下面的代码段说明了我的插件的外观:
<?php
/*
Plugin Name: XXXXX
Plugin URI: XXXXX
Description: XXXXX
Version: 1.0
Author: XXXXX
Author URI: XXXXX
License: GNU
*/
echo"test";
?>
导致此错误的原因是什么?如何解决?
答案 0 :(得分:1)
有几个问题:
您的插件不应该直接$validParams = array(
'individual' => array(
'firstName' => "Joe",
'lastName' => "Bloggs",
'email' => "joe@bloggs.com",
'phone' => "555-555-5555",
'address' => array(
'streetAddress' => "123 Credibility St.",
'postalCode' => "60606",
'locality' => "Chicago",
'region' => "IL",
),
'dateOfBirth' => "10/9/1980",
'ssn' => "123-00-1234",
),
'business' => array(
'dbaName' => "Robot City",
'legalName' => "Robot City INC",
'taxId' => "123456789",
),
'funding' => array(
'routingNumber' => "122100024",
'accountNumber' => "43759348798",
'destination' => Braintree_MerchantAccount::FUNDING_DESTINATION_BANK,
'descriptor' => 'Joes Bloggs MI',
),
'tosAccepted' => true,
'masterMerchantAccountId' => "sandbox_master_merchant_account"
);
$result = Braintree_MerchantAccount::create($validParams);
任何内容。相反,如果您需要测试,请将echo
添加到WordPress挂钩。例如,将您的echo
替换为:
echo "test";
建议您删除结束add_action( 'init', function() { echo 'test'; });
标记,以避免&#34;已发送标题&#34;通知。