Skip to main content
added 419 characters in body
Source Link

Since PHP 5.3 you can use thhe formthe shortcut $a = $b? : $c:

$this->uniqueSessionKey = $settings->get('uniqueSessionKey') ?  : $_SERVER['HTTP_USER_AGENT'] . time();

--

Just a note: you can not use this if you want check if the var $a is set. In this case you must use the original form: $a = isset($b)? $b : $c;

Otherwise, you can write a custom function in this way:

function getIfSet(&$a, $default = null) {
      return isset($a)? $a : $default;
} 

$a = getIfSet($b,$c);

Passing var by reference (&$a) avoid the PHP notice if $a is not set.

Since PHP 5.3 you can use thhe form $a = $b? : $c:

$this->uniqueSessionKey = $settings->get('uniqueSessionKey') ?  : $_SERVER['HTTP_USER_AGENT'] . time();

Since PHP 5.3 you can use the shortcut $a = $b? : $c:

$this->uniqueSessionKey = $settings->get('uniqueSessionKey') ?  : $_SERVER['HTTP_USER_AGENT'] . time();

--

Just a note: you can not use this if you want check if the var $a is set. In this case you must use the original form: $a = isset($b)? $b : $c;

Otherwise, you can write a custom function in this way:

function getIfSet(&$a, $default = null) {
      return isset($a)? $a : $default;
} 

$a = getIfSet($b,$c);

Passing var by reference (&$a) avoid the PHP notice if $a is not set.

Source Link

Since PHP 5.3 you can use thhe form $a = $b? : $c:

$this->uniqueSessionKey = $settings->get('uniqueSessionKey') ?  : $_SERVER['HTTP_USER_AGENT'] . time();