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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745422572a4627031.html
评论列表(0条)