I want to extract function args from the calling function, the issue is that sometimes it can be 3 args and sometimes four.
How I can extract args to variables without getting an undefined warning or similar?
If there is a way the undefined variable can be null or false it's ok too.
Here is an example.
Notice: This is just an example in my case I can't just pass the variables.
<?php
function sendMail( $to, $subject, $body, $headers ) {
sendSmtp();
}
function sendSmtp() {
$backtrace = debug_backtrace();
// This will cause a notify because $attachment is not defined.
list( $to, $subject, $body, $headers, $attachment ) = $backtrace[0]['args'];
}