rfc:isset-set-operator

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
rfc:isset-set-operator [2013/11/30 16:10] chrislondonrfc:isset-set-operator [2017/09/22 13:28] (current) – external edit 127.0.0.1
Line 4: Line 4:
   * Date: 2013-11-24   * Date: 2013-11-24
   * Author: Chris London, me chrislondon co   * Author: Chris London, me chrislondon co
-  * Status: Draft+  * Status: Draft (Inactive)
  
 ===== Introduction ===== ===== Introduction =====
Line 24: Line 24:
 ??: will be equivalent to the ternary short hand ?: except that it also checks for isset(). ??: will be equivalent to the ternary short hand ?: except that it also checks for isset().
  
-    $foo = $bar ??: 'other';+    // $bar is unset
          
-    // which is functionally equivalent to:+    $foo = $bar ?: 'other'; // Throws undefined notice 
 +     
 +    $foo = $bar ??: 'other'; // Does NOT throw undefined notice 
 +     
 +    // ??: is functionally equivalent to:
     $foo = (isset($bar) && $foo) ? $bar : $other;     $foo = (isset($bar) && $foo) ? $bar : $other;
          
-This will be very helpful echoing default variables in HTML like so:+This will be very helpful for echoing default variables in HTML like so:
  
     <div class="<?= $user ??: 'guest' ?>"> ... </div>     <div class="<?= $user ??: 'guest' ?>"> ... </div>
Line 47: Line 51:
 ===== Open Issues ===== ===== Open Issues =====
  
-To be added+**Possible Alternatives To ?= Operator** 
 + 
 +  - ?:= 
 +  - ||= 
 +  - @= 
 + 
 +**Possible Alternatives To ??: Operator** 
 + 
 +  - ?:: 
 +  - ?: (backward compatibility concerns) 
 +  - || (backward compatibility concerns) 
 +  - @:
  
 ===== Unaffected PHP Functionality ===== ===== Unaffected PHP Functionality =====
rfc/isset-set-operator.1385827810.txt.gz · Last modified: 2017/09/22 13:28 (external edit)