You have some errors in your operators like ")" missing or too many.
You can also use the null coalescing assignment operator
??= to simplify the code -
PHP Null Coalescing Operator[
^]
I have changed your code a little as base_url as undefined might also return some unknown errors and it is way shorter and more reliable -
function base_url() {
$loc ??= 0;
$dept ??= 0;
$e_name ??= 0;
return 'report/print/' . $loc . '/' . $dept . '/' . $e_name;
}
You can now make a call to your base_url function -
<a href="<?= $url = base_url(); ?>"><?=print_r($url);?></a>
The print_r will show you the returned values of each variable.