function foobar($arg, $arg2) {
echo __FUNCTION__, " got $arg and $arg2\n";
}
foobar('one','two'); // OUTPUTS : foobar got one and two
call_user_func_array("foobar", array("one", "two")); // // OUTPUTS : foobar got one and two
Run Code Online (Sandbox Code Playgroud)
我可以看到常规call_user_func_array方法和 方法都输出相同,那么为什么要选择它呢?
在哪种情况下,常规调用方法会失败,但call_user_func_array不会?
我能得到这样的例子吗?
谢谢
有没有办法我们可以为已经创建的小部件分配一个短代码,然后再使用它
在我们的特定帖子和页面中的短代码,以显示小部件而不是琐碎的方法
在侧边栏中显示小部件?我用谷歌搜索这个东西没找到任何相对的东西.
任何建议都会受到欢迎!
想在wordpress的插件页面中制作可拖动和可排序的部分,就像我们在仪表板上看到的那样.我试着寻找,但dint得到了我想要的.这是一段代码虽然它添加了两个div,界面类似于仪表板中的可拖动界面,但我无法拖动.
<div class="wrap">
<h2>I like to move it, move it</h2>
<div class="meta-box-sortables ui-sortable">
<div class="postbox" id="p1">
<h3 class="hndle">Drag me around, babe</h3>
<div class="container">
<p>Your content goes here</p>
</div>
</div><!-- .postbox -->
<div class="postbox" id="p2">
<h3 class="hndle">Drag me, too</h3>
<div class="container">
<p>Your content goes here, again</p>
</div>
</div><!-- .postbox -->
</div><!-- .meta-box-sortables.ui-sortable-->
</div><!-- .wrap -->
<?php
function move_me_around_scripts() {
wp_enqueue_script('dashboard');
wp_enqueue_script( 'jquery-ui-sortable');
}
function admin_page_with_draggable_boxes(){
$my_page = add_dashboard_page( 'moveit', 'moveit', 'read',
'moveit' );
add_action('load-'.$my_page, 'move_me_around_scripts');
}
add_action('admin_menu', 'admin_page_with_draggable_boxes'); ?>
Run Code Online (Sandbox Code Playgroud) 我有一个国家列表作为数组..我希望这个数组以下格式以后通过ajax返回: -
"印度","美国","英国"..
使用以下代码得到一些我正在寻找..
foreach($country_list as $country) {
$countries .= '"'.$country['label'].'",';
}
Run Code Online (Sandbox Code Playgroud)
问题是它是输出像"印度","美国","英国",...即尾随逗号.
试图删除它
substr_replace($countries, "0", -1);
Run Code Online (Sandbox Code Playgroud)
和
rtrim($countries, ",");
Run Code Online (Sandbox Code Playgroud)
但没有工作!.. 请帮忙 !