我一直在学习PHP,看到人们如何命名的东西有很多变化.我渴望至少与自己保持一致.
我应该在哪里使用Camel Case以及我应该在哪里使用下划线?
思考:
变量/属性:$userid或$user_id或$userID
课程:MyCustomClass或myCustomClass
功能/方法:my_custom_function()或my_Custom_Function()
任何想法都赞赏.
我正在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)