函数在PHP邮件正文中不起作用

函数在PHP邮件正文中不起作用,php,wordpress,function,email,Php,Wordpress,Function,Email,我用它发送一封基本的电子邮件: // Email details $name = 'Davo'; $recipient = 'info@davo.com'; $from = 'sender@example.com' $subject = 'Testing'; // All plugins function the_plugins() { $the_plugs = get_option('active_plugins'); foreach($the_plugs as $key

我用它发送一封基本的电子邮件:

// Email details
$name = 'Davo';
$recipient = 'info@davo.com';
$from = 'sender@example.com'
$subject = 'Testing';

// All plugins
function the_plugins() {
    $the_plugs = get_option('active_plugins'); 
    foreach($the_plugs as $key => $value) { 
        $string = explode('/',$value); print $string[0] . '<br />';
    }
}

// Message
$body = '<p>Hello' . $name . ',</p>';
$body .= '<p>Your website has these plugins:</p>';
$body .= the_plugins();
$body .= '<p>Have a nice day.</p>';

$headers[]  = 'Content-type:text/html;charset=UTF-8';
$headers[]  = 'From' . $name. ' <' . $from . '>';
$headers[]  = 'Reply-To: ' . $from;
$headers[]  = 'MIME-Version: 1.0';
wp_mail($recipient, $subject, $body, $headers);
仅供参考
插件()
功能正常。我能够
回显_插件();退出就在函数之后,它返回一个插件列表,因此函数本身不是问题所在

有什么建议吗?

试试这个

function the_plugins() {
    $the_plugs = get_option('active_plugins'); 
    $plugins = '';
    foreach($the_plugs as $key => $value) { 
        $string = explode('/',$value); 
        $plugins .= $string[0] . '<br />';
    }
   return $plugins;
}
function\u插件(){
$the_plugs=get_选项(“active_plugins”);
$plugins='';
foreach(_插件为$key=>$value){
$string=explode(“/”,$value);
$plugins.=$string[0]。
; } 返回$plugins; }
从函数返回字符串。并删除print语句。@ShoyebSheikh您的意思是:
return$string=explode(“/”,$value);打印$string[0]。'
如果我这样做,它将返回
数组
我发布了一个答案
function the_plugins() {
    $the_plugs = get_option('active_plugins'); 
    $plugins = '';
    foreach($the_plugs as $key => $value) { 
        $string = explode('/',$value); 
        $plugins .= $string[0] . '<br />';
    }
   return $plugins;
}