php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #10695 Class Properties are not accepted by for each structures
Submitted: 2001-05-07 02:16 UTC Modified: 2001-05-07 03:41 UTC
From: estephano at estephano dot de Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 4.0.4pl1 OS: Linux Redhat 6.2
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: estephano at estephano dot de
New email:
PHP Version: OS:

 

 [2001-05-07 02:16 UTC] estephano at estephano dot de
Hello.

I have got a "standard" install of PHP 4.0.4pl1. So there is nothing special about it.

Here is the code extract:

#$result Data is successfully retrieved from mysql database)
class auth_user {
var $md_paketnummern;
function auth_user($username,$password,$database,$auth_table,$conn_id) {
$this->md_paketnummern=explode("|",$result[pakete]);
}
}

class fetch_pakete {
	function fetch_pakete(){
# Now comes the LINE!!!	
foreach($newuser->md_paketnummern as $arraykey => $paketnummern){
			echo $paketnummern;
		}
	}
}


Now I call $newuser = new auth_user;
then: netpaket = new fetch_pakete;

When I replace $newuser->md_paketnummern with an argument, it works fine. With this version it does not.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-05-07 03:41 UTC] cardinal@php.net
This is a scoping issue.  In order to see $newuser from within the fetch_pakete method, you need to declare $newuser global.

http://www.php.net/manual/en/language.variables.scope.php
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Nov 14 03:01:30 2019 UTC