admin管理员组文章数量:1425664
When i'm going to active my plugin that i create for sample , wordpress got me 1 unexpected output during activation !
This plugin actually has nothing but a Shortcode that will echo Hello !
I followed these steps but nothing didn't change :
1- save My plugin with other names ( Folder and plugin name etc.)
2- Copy/paste codes in other php file that i created in Cpanel file manager
3- changing my encode to UTF-8 (Without BOM ) in Notepad++
Please help me with this issue. my plugin code is
<?php
/*
* Plugin Name: ARU V1
* Plugin URI: Mysiteadress
* Description: arv
* Author: Myname was here
* Author URI: Mysiteadress
* Version: 1.5
* Text Domain: pnl
*/
function upnl() {
echo "hello";
}
add_shortcode( 'pnlsc', 'upnl' );
?>
When i'm going to active my plugin that i create for sample , wordpress got me 1 unexpected output during activation !
This plugin actually has nothing but a Shortcode that will echo Hello !
I followed these steps but nothing didn't change :
1- save My plugin with other names ( Folder and plugin name etc.)
2- Copy/paste codes in other php file that i created in Cpanel file manager
3- changing my encode to UTF-8 (Without BOM ) in Notepad++
Please help me with this issue. my plugin code is
<?php
/*
* Plugin Name: ARU V1
* Plugin URI: Mysiteadress
* Description: arv
* Author: Myname was here
* Author URI: Mysiteadress
* Version: 1.5
* Text Domain: pnl
*/
function upnl() {
echo "hello";
}
add_shortcode( 'pnlsc', 'upnl' );
?>
Share
Improve this question
asked Jun 9, 2019 at 12:27
TheXrionTheXrion
57 bronze badges
1 Answer
Reset to default 2It is bad practice to end a PHP only file with the PHP closing tag (?>) as it may lead to a new line or any other character being output before the headers or other functions and thus creating problems like the one you mention.
Whenever you create/edit a PHP file, don't close it, if you have to include HTML, close and open the PHP tags again.
https://php/basic-syntax.instruction-separation
The closing tag of a PHP block at the end of a file is optional, and in some cases omitting it is helpful when using include or require, so unwanted whitespace will not occur at the end of files, and you will still be able to add headers to the response later. It is also handy if you use output buffering, and would not like to see added unwanted whitespace at the end of the parts generated by the included files.
Best regards.
本文标签: phpPlugin Generate Unexpected output during activation
版权声明:本文标题:php - Plugin Generate Unexpected output during activation 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745422572a2657967.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论