Search
 
SCRIPT & CODE EXAMPLE
 

PHP

what does ? mean in PHP

/* 
in php, ? is the 'Ternary Operator'.

The expression (expr1) ? (expr2) : (expr3) evaluates 
to expr2 if expr1 evaluates to true, and expr3 if 
expr1 evaluates to false.

It is possible to leave out the middle part of the 
ternary operator. Expression expr1 ?: expr3 evaluates 
to the result of expr1 if expr1 evaluates to true, 
and expr3 otherwise. expr1 is only evaluated once in 
this case.
*/

<?php
// Example usage for: Ternary Operator
$action = (empty($_POST['action'])) ? 'default' : $_POST['action'];

// The above is identical to this if/else statement
if (empty($_POST['action'])) {
    $action = 'default';
} else {
    $action = $_POST['action'];
}
?>
Comment

PREVIOUS NEXT
Code Example
Php :: how to change php to html 
Php :: unable to composer require apidoc yii2 
Php :: PHP detect spam name 
Php :: confiruando passaport no laravel 
Php :: phpexcel set data type 
Php :: generate rand password php 
Php :: Comment exiger une longueur minimale de commentaire dans WordPress 
Php :: alert in php after header location 
Php :: Laravel You may determine if a template inheritance section has content using the @hasSection directive: 
Php :: php?gs=3 
Php :: implement class in autoloader athow to implment data table in laravel project 
Php :: php how to loop through array_rand 
Php :: markdown mail html rendering laravel 
Php :: unisharp laravel, Tai anh? 
Php :: php curl get text only 
Php :: validate unique or equal 
Php :: cout post on category in controller laravel 
Php :: King Composer Theme Export 
Php :: omnipay capture 
Php :: controller run 
Php :: hide my echo from page php 
Php :: Laravel, return view with Request::old 
Php :: customly add reviews from code site reviews wp 
Php :: image_store 
Php :: withCount laravel assign generic name 
Php :: PHP readfile() Function 
Php :: Fehler beim Uploadtest der ausgewählten Datei. 
Php :: sub() vs substr in php 
Php :: php check how long a function took to exexute 
Php :: laravel Join columns of Day, Month , Year to calculate age 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =