Edit report at https://bugs.php.net/bug.php?id=62435&edit=1

 ID:                 62435
 Comment by:         dagguh at gmail dot com
 Reported by:        grzegorz129 at gmail dot com
 Summary:            Shorted if and references handling
 Status:             Open
 Type:               Feature/Change Request
 Package:            Scripting Engine problem
 Operating System:   N/A
 PHP Version:        5.4.4
 Block user comment: N
 Private report:     N

 New Comment:

"Short if" is known as ternary operator.

What you want to write is:
$this->_currentExceptionInfo =& ((isset($this->_exceptionsMap[$code])) ? $this-
>_exceptionsMap[$code] : $this->_exceptionsMap[self::X_INTERNAL]);

BTW. Using references is a bad idea.
This request is invalid.


Previous Comments:
------------------------------------------------------------------------
[2012-06-28 09:41:09] grzegorz129 at gmail dot com

Description:
------------
PHP doesn't allow to use references in short if construction - I don't have 
idea 
why it's limited. I think it should be improved in future releases.

Test script:
---------------
$this->_currentExceptionInfo = ((isset($this->_exceptionsMap[$code])) ? 
&$this->_exceptionsMap[$code] : &$this->_exceptionsMap[self::X_INTERNAL]); 
//Error

//The same function but it works as expected
if(isset($this->_exceptionsMap[$code])) $this->_currentExceptionInfo = 
&$this->_exceptionsMap[$code];
else $this->_currentExceptionInfo = &$this->_exceptionsMap[self::X_INTERNAL];



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=62435&edit=1

Reply via email to