php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #49016 Remove notice error on ?: (undefined index)
Submitted: 2009-07-22 13:50 UTC Modified: 2010-11-24 15:32 UTC
Votes:4
Avg. Score:4.8 ± 0.4
Reproduced:3 of 3 (100.0%)
Same Version:3 (100.0%)
Same OS:1 (33.3%)
From: ivan1986 at list dot ru Assigned:
Status: Wont fix Package: Scripting Engine problem
PHP Version: 5.3.0 OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2009-07-22 13:50 UTC] ivan1986 at list dot ru
Description:
------------
When using undefined variable in ?: php generate notice

in php 5.2.x very often use this code

$inp = isset($_POST['inp']) ? $_POST['inp'] : 'def_inp';

in php 5.3 want use a shorter code

$inp = $_POST['inp'] ?: 'def_inp';

Reproduce code:
---------------
<?php

$inp = $_POST['inp'] ?: 'def_inp';
echo $inp;

?>

Expected result:
----------------
def_inp

Actual result:
--------------
Notice: Undefined index: inp in /path/to/to/index.php on line 3
def_inp

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-11-24 15:19 UTC] jani@php.net
-Summary: Pleace no generate Notice on ?: +Summary: Remove notice error on ?: (undefined index) -Package: Feature/Change Request +Package: Scripting Engine problem
 [2010-11-24 15:32 UTC] jani@php.net
-Status: Open +Status: Wont fix
 [2010-11-24 15:32 UTC] jani@php.net
For reasoning on the notice: http://markmail.org/message/ivexk3smqa2kfipq

Conclusion: It will stay.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 17:01:30 2024 UTC