For Programmers: Free Programming Magazines  


Home > Archive > PHP Documentation > July 2006 > #38240 [NEW]: Change prev() and next() documentation









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author #38240 [NEW]: Change prev() and next() documentation
paul at stunning-stuff dot com

2006-07-27, 9:57 pm

From: paul at stunning-stuff dot com
Operating system:
PHP version: Irrelevant
PHP Bug Type: Documentation problem
Bug description: Change prev() and next() documentation

Description:
------------
The documentation for prev() states the following:

"Returns the array value in the previous place that's pointed to by the
internal array pointer, or FALSE if there are no more elements."

After reading this I was expecting prev() to only change the array
pointer's position if there is a previous element and return false
(without changing the pointer's position) if there isn't a previous
element.

This misconception caused a bug in my code and it took me quite some time
to figure out the problem.

I would suggest you change the text to make it less ambiguous.

The next() documentation is a little more clear, but could also use some
disambiguation.

Bug report #37598 shows that I am not the only one who misunderstood the
docs. The final paragraph in the final post in that bug report is a good
explanation of how prev() and next() work:

"You should check the return value of prev and next. The state is
undefined as out of range. Reset the array after having reached the end
or beginning."

Thanks for your time and effort,

Paul van der Maas


--
Edit bug report at http://bugs.php.net/?id=38240&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=38240&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=38240&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=38240&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=38240&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=38240&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=38240&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=38240&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=38240&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=38240&r=support
Expected behavior: http://bugs.php.net/fix.php?id=38240&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=38240&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=38240&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=38240&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=38240&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=38240&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=38240&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=38240&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=38240&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=38240&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=38240&r=mysqlcfg
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com