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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ijb_green at hotmail dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 12:01:33 2025 UTC