I know it is an easy question but for a new bie it is not, I want to know the job of question mark here.
$name=isset($_POST[“name”]) ? $_POST[‘name’] : “”;
$area=isset($_POST[“area”]) ? $_POST[‘area’] : “”;
The function of the question mark is that of a ternary operator:
PHP: Comparison Operators - Manual
It is the same as writing the following:
if ( isset( $_POST[‘name’] ) ) {
$name = $_POST[‘name’];
}
else {
$name = ‘’;
}
I’m a newbie too, but this is my understanding. The ? goes in tandem with the :
The line is saying: let’s assign a value to $name. The question mark is saying ‘is “name” set? If so, assign $_POST[‘name’] to this variable’. The : is saying ‘if not, then assign “” to it’.
EDIT: got distracted by a phone call before clicking Post. Cute Tink’s answer is better.