- debug_backtrace: documentation ( source)
- print_r: documentation ( source)
<?php
function strict()
{
$backtrace = debug_backtrace(0, 2);
if (false === $backtrace || count($backtrace) !== 1) {
throw new \RuntimeException('strict() must be called from within a function');
}
$expectedTypes = func_get_args();
print_r($backtrace);
}
function myargs($a, $b)
{
strict('string', 'int');
echo 'Hello';
}
myargs('hello', 4);