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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ivan1986 at list dot ru
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 12:01:36 2025 UTC