Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 函数显示错误_Php_Wordpress - Fatal编程技术网

Php 函数显示错误

Php 函数显示错误,php,wordpress,Php,Wordpress,嗨,我试图使用一个函数,我得到这个错误 Parse error: syntax error, unexpected 'function' (T_FUNCTION) on line 3 附上代码 <?php add_action('admin_menu', 'zkr_my_theme_menu_first'); // we need this action to create the menu // this makes the menu function zkr_my_the

嗨,我试图使用一个函数,我得到这个错误

Parse error: syntax error, unexpected 'function' (T_FUNCTION) on line 3
附上代码

<?php

add_action('admin_menu', 'zkr_my_theme_menu_first'); // we need this action to create     the menu
// this  makes the menu
function zkr_my_theme_menu_first()
{
$page_title = "Theme Settings";
$menu_title = "Theme Settings";
$capability = "administrator";
$menu_slug = "zkr-theme-settings";
$function = "zkr_main_theme_menu";
$icon_url = get_template_directory_uri() . "/zkrframework/images/settings_icon.gif";

add_menu_page($page_title,$menu_title,$capability,$menu_slug, $function, $icon_url);

}
// this shows the menu html think of it as the view.
function zkr_main_theme_menu() 
{
$current_user = wp_get_current_user();
$user_id = $current_user->ID;
if ( !user_can( $user_id, 'create_users' ) )
    return false;
?>

<div class="wrap">

<h2>Hello Menu</h2>

</div>

<?php
}

?>

你好菜单
我试图添加一个菜单到我的wordpress管理面板,我得到这个错误

Parse error: syntax error, unexpected 'function' (T_FUNCTION) on line 3

如何修复此错误?

您在第3行调用函数addAction(),但尚未在提供的代码示例中声明它


在声明函数之前调用函数是可以的,但是当调用未定义的函数时,解释器会用一个隐喻性的“wtf”耸耸肩。

add\u action是一个内置的Wordpress函数。在这一刻,我测试了您的代码,结果是可以的。请再试一次。