php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15737 isset() dont work with $str[$index]
Submitted: 2002-02-26 13:52 UTC Modified: 2002-02-26 14:03 UTC
From: Beater at orgalan dot de Assigned:
Status: Not a bug Package: Strings related
PHP Version: 4.1.1 OS: Win32 / Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: Beater at orgalan dot de
New email:
PHP Version: OS:

 

 [2002-02-26 13:52 UTC] Beater at orgalan dot de
<?php
function test($foo = 'bar')
{	
	for($i=0; $i<5; $i++)
	{
		!isset($foo[$i]) ? $foo[$i] = 0 : 0;
		
		echo $foo[$i];
	}
}

test();
?>

works fine on 4.0.6; 4.1.1 (linux and win32) announces

"Uninitialized string offset on line 6..."

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-02-26 14:03 UTC] zak@php.net
The issues is not isset().  PHP generates an warning when attempting to access a string subscript that does not exist.

If the level error reporting is set to E_ALL, this warning will be generated. 

A better way to do this would be to use strlen().
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 15:01:28 2024 UTC