小编Lin*_*ton的帖子

什么时候应该在PHP命名中使用camelCase/Camel Case或下划线?

我一直在学习PHP,看到人们如何命名的东西有很多变化.我渴望至少与自己保持一致.

我应该在哪里使用Camel Case以及我应该在哪里使用下划线?

思考:

  • 变量/属性:$userid$user_id$userID

  • 课程:MyCustomClassmyCustomClass

  • 功能/方法:my_custom_function()my_Custom_Function()

任何想法都赞赏.

php naming camelcasing naming-conventions

9
推荐指数
2
解决办法
6712
查看次数

在WooCommerce Email Hook中运行的参数太少

我正在PHP中创建一个函数,我想在下面传递三个参数:

function lnz_wc_emails_memberreceipients($headers, $object, $order) {

$company = $order->billing_company;

$emailreturn = array (
    'Robin' => "weiltest@weiltest.com",
    'Other' => "beistest@beistest.com, beistest2@beistest.com"
);

$headers = array();
$headers[] = 'Bcc: your name '.$emailreturn[$company];
$headers[] = 'Content-Type: text/html';
return $headers;

}
add_filter( 'woocommerce_email_headers', 'lnz_wc_emails_memberreceipients', 10, 2);
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试这样做时,我得到一个错误,表明我的函数要求3个参数,但只传递了两个.

Fatal error: Uncaught ArgumentCountError: Too few arguments to function lnz_wc_emails_memberreceipients(), 2 passed in /home/benefacto/public_html/dev3/wp-includes/class-wp-hook.php on line 300 and exactly 3 expected in /home/benefacto/public_html/dev3/wp-content/plugins/bnfo-custom-emails/bnfo-custom-emails.php:17 Stack trace: #0 /home/benefacto/public_html/dev3/wp-includes/class-wp-hook.php(300): lnz_wc_emails_memberreceipients('Content-Type: t...', 'customer_comple...') #1 /home/benefacto/public_html/dev3/wp-includes/plugin.php(203): WP_Hook->apply_filters('Content-Type: t...', Array) #2 /home/benefacto/public_html/dev3/wp-content/plugins/woocommerce/includes/emails/class-wc-email.php(287): …
Run Code Online (Sandbox Code Playgroud)

php wordpress woocommerce

1
推荐指数
1
解决办法
2019
查看次数