I wonder if it is possible to exit a function e.g. by return in the second statement of a null coalescing operator in PHP.
I want to use this to check some POST data in a function and exit the function if a POST var is not set.
This would be clean code without the painful if(isset(...)).
Example script file:
<?php
// Controller
$id = $_POST['id'] ?? add();
function add(){
$var1 = $_POST['var1'] ?? return; // <-- is this possible or some similar solution?
$var2 = $_POST['var2'] ?? return;
// All POST vars are set: do something
// ...
}