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函数。在这一刻,我测试了您的代码,结果是可以的。请再试一次。