dwest100 Posted March 17, 2021 Share Posted March 17, 2021 I have this function which works except it throws a Notice regarding the 3rd line of the function. The Notice reads "Only variables should be passed by reference..." What am I doing wrong in that 3rd line—$caller = next(debug_backtrace()) [‘function’]; ? Thanks for any assistance! //EMAIL_ADMIN //Sends email to site admin if email testing services fail. //Only occurs if both primary and secondary services have failed. //Calls no other function. //Called by test_email function. //*************************************************************** function email_admin($email){ global $full_site_url;//used in links. global $site_title;//used in confirmation messages. $caller = next(debug_backtrace())['function']; //assigns calling function name to $caller. if ($caller == 'alt_test_email'){ //used in email message to provide links for checking services. $primary_service = 'http://www.quickemailverification.com';//used in email message. $secondary_service = 'http://www.neverbounce.com';//used in email message. $to = get_bloginfo('admin_email'); $subject = 'EMAIL TESTING SERVICES HAVE FAILED!'; $message = 'Both email testing services have failed. Go to ' . $primary_service . ' and ' . $secondary_service . '.'; dw_send_email($to, $subject, $message);//call email sending function. } if ($caller == 'unsubscribe'){ $to = get_bloginfo('admin_email'); $subject = $site_title . " unsubscribe"; $message = $email . " has unsubscribed."; dw_send_email($to, $subject, $message);//call email sending function. } if ($caller == 'subscribe_form_display'){ $to = get_bloginfo('admin_email'); $subject = "New " . $site_title . " subscriber"; $message = $email . " has subscribed to " . $site_title . "."; dw_send_email($to, $subject, $message);//call email sending function. } } Quote Link to comment https://forums.phpfreaks.com/topic/312305-debug_backtrace-notice-what%E2%80%99s-causing-it-in-my-code/ Share on other sites More sharing options...
requinix Posted March 17, 2021 Share Posted March 17, 2021 next() operates on array variables. You are trying to give it an array that is not a variable. It's trying to get the second item in that backtrace array. Use regular array offset [ ] notation instead - yes, you can do it right after a function call. Quote Link to comment https://forums.phpfreaks.com/topic/312305-debug_backtrace-notice-what%E2%80%99s-causing-it-in-my-code/#findComment-1585146 Share on other sites More sharing options...
Solution dwest100 Posted March 17, 2021 Author Solution Share Posted March 17, 2021 Thanks much! I will do that 🙂 Quote Link to comment https://forums.phpfreaks.com/topic/312305-debug_backtrace-notice-what%E2%80%99s-causing-it-in-my-code/#findComment-1585161 Share on other sites More sharing options...
dwest100 Posted March 23, 2021 Author Share Posted March 23, 2021 Got it squared away! Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/312305-debug_backtrace-notice-what%E2%80%99s-causing-it-in-my-code/#findComment-1585295 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.