php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5588 Returned values from a declared function are cutoff
Submitted: 2000-07-14 10:28 UTC Modified: 2000-07-14 10:32 UTC
From: malmond at vt dot edu Assigned:
Status: Closed Package: Other
PHP Version: 4.0.0 OS: Linux x86 and PPC and FreeBSD 3.
Private report: No CVE-ID: None
 [2000-07-14 10:28 UTC] malmond at vt dot edu
what is happening on all the above mentioned platforms is that a function that is declared when it returns more than one value it will only return the first character from each return.

function foo() {
   hit database with sql statement
   (this also works with other statements, not just db)
   get the results (fetch_row)
   return($row[0]); // eq Well
   return($row[1]); // eq Hello
   return($row[2]); // eq Dolly
} // end function

$myVals = foo();
print($myVals[0]); // prints "W" 
print($myVals[1]); // prints "H" 
print($myVals[2]); // prints "D" 

this has occurred on many platforms all running PHP 4.0.0 ( can not get a working binary of 4.0.1; compile errors) with either hitting MySQL (3.22.32 and 3.23.19) and PostgreSQL 7.0.2; as well as by executing a general statement in the function.  This occurs only with multiple returns from a function with a single return there is no problem.

The platforms are Linux 2.2.15 Mandrake 6.1, FreeBSD 3.5 and 4, YellowDog LinuxPPC Champion 1.2. All compiled with the following: 

'./configure' '--with-apxs=/usr/local/apache/bin/apxs' '--with-config-file-path=/etc/httpd' '--enable-track-vars' '--enable-magic-quotes' '--enable-calendar' '--with-jpeg-dir=/usr/local/jpeg' '--with-tiff=/usr/include' '--with-db3=/usr/local/BerkeleyDB.3.1' '--enable-ftp' '--with-gd=/usr/local/gd' '--with-ttf=/usr/include/freetype' '--with-ldap=/usr/local/openldap' '--with-mysql=/usr/local/mysql' '--with-pgsql=/usr/local/pgsql' '--enable-trans-sid' '--enable-memory-limit' '--with-gnu-ld' '--with-png=/usr/local'


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-07-14 10:32 UTC] stas at cvs dot php dot net
What are you trying to do? PHP can't do multiple returns, and you are returning string, so $myVals[0] is first character of $myVals.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 19:01:28 2024 UTC