php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52064 while loop does not meet conditions
Submitted: 2010-06-12 12:51 UTC Modified: 2010-06-14 10:58 UTC
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:1 (50.0%)
From: developers at proneticas dot net Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.3.2 OS: FreeBSD
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: developers at proneticas dot net
New email:
PHP Version: OS:

 

 [2010-06-12 12:51 UTC] developers at proneticas dot net
Description:
------------
I am seeing a bug in PHP 5.3 where the WHILE LOOP is not meeting all of the conditions. The same code was working great in PHP 5.2 but broke after a PHP upgrade. I reviewed the PHP 5.3 change-log and nothing is mentioned for changes in WHILE LOOP conditions.


Test script:
---------------
<?php

function cutTextPer($string, $setlength) {
    $rlength = $setlength;
    if($rlength<strlen($string)){
	while (($string{$rlength} != '.') && ($rlength > 0)) {
	    $rlength--;
	}
	if ($rlength== 0) {
		return substr($string, 0, $setlength);
	} else {
		return substr($string, 0, $rlength).'.';
	}
    }else {
	return $string;
    }
}

$mstr = 'ProNeticas has released a visual rapid database design tool. This allows you to generate online programs in rapid time, without any programming.';

print cutTextPer( (String)$mstr, 52);

?>

[OUTPUT IN PHP 5.2]
ProNeticas has released a visual rapid database design tool.

[OUTPUT IN PHP 5.3]
ProNeticas has released a visual rapid database de


Expected result:
----------------
ProNeticas has released a visual rapid database design tool.

Actual result:
--------------
ProNeticas has released a visual rapid database de

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-06-12 18:36 UTC] felipe@php.net
-Status: Open +Status: Feedback
 [2010-06-12 18:36 UTC] felipe@php.net
Which 5.2 release are you refering to?
 [2010-06-13 00:57 UTC] developers at proneticas dot net
Well really any version of 5.2 was working correctly, but for the sake of debugging, the last version of 5.2 installed was 5.2.12.
 [2010-06-14 10:58 UTC] fa@php.net
-Status: Feedback +Status: Bogus
 [2010-06-14 10:58 UTC] fa@php.net
$ /opt/src/php-5.2.13/sapi/cli/php b52064.php
string(52) "ProNeticas has released a visual rapid database desi"

$ /opt/src/php-5.3.1/sapi/cli/php b52064.php
string(52) "ProNeticas has released a visual rapid database desi"

$ /usr/bin/php -v
PHP 5.2.6-1+lenny8 with Suhosin-Patch 0.9.6.2 (cli)[...]
$ /usr/bin/php b52064.php
string(52) "ProNeticas has released a visual rapid database desi"
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 14:01:32 2024 UTC