php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32793 foreach chage the type from object to string
Submitted: 2005-04-21 22:10 UTC Modified: 2005-04-21 22:22 UTC
From: ijb_green at hotmail dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 4.3.10 OS: Linux 2.6.9-1.667
Private report: No CVE-ID: None
 [2005-04-21 22:10 UTC] ijb_green at hotmail dot com
Description:
------------
When i iterate a array that contains Objects asociated with a numeric key  foreach statement changes the type of the variable from object to string then i can't access to the object methods but i can acces to its attributes. 

Reproduce code:
---------------
foreach ($Resultados as $Clave=>$Objeto){
	if($Clave!="Count" ||$Clave!="LegislaturaRomano"){
printf("<td class='tddatosazul'>%s</td>",$Objeto->denomiCorta); //Access to the object attribute

printf("<td class='tddatosazul'>%s</td>",//access object's method here it fails
$Objeto->getTotalInicitivasDictaminadas());

...

Expected result:
----------------
Display the result of the method getTotalInicitivasDictaminadas it only adds two values

Actual result:
--------------
Fatal error: Call to a member function on a non-object 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-04-21 22:22 UTC] tony2001@php.net
Do not file bugs when you have Zend extensions (zend_extension=)
loaded. Examples are Zend Optimizer, Zend Debugger, Turck MM Cache,
APC, Xdebug and ionCube loader.  These extensions often modify engine
behavior which is not related to PHP itself.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 01:01:28 2024 UTC