AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

[PHP] Objektliste

Ein Thema von Luckie · begonnen am 3. Feb 2012 · letzter Beitrag vom 3. Feb 2012
 
Benutzerbild von Luckie
Luckie

Registriert seit: 29. Mai 2002
37.621 Beiträge
 
Delphi 2006 Professional
 
#1

[PHP] Objektliste

  Alt 3. Feb 2012, 18:45
Ich überarbeite gerade ein privates Projekt und versuche gerade eine Objektliste zu erstellen.

Klasse Conatct:
Code:
<?php
   class Contact
   {
      private $Name = "";
      private $Vorname = "";
      
      public function SetName($Name) {
         $this->Name = $Name;
      }
      
      public function GetName() {
         return $this->Name;
      }
      
      public function SetVorname($Vorname) {
         $this->Vorname = $Vorname;
      }
      
      public function GetVorname() {
         return $tis->Vorname;
      }
   }
?>
Klasse ContactList:
Code:
<?php
   class ContactList {
      
      private $Contact;
      private $List = array();
      
      public function SetContact($Contact) {
         $this->Contact = $Contact;
      }
      
      public function Add($Contact) {
         array_push($this->List, $Contact);
      }
   }
?>
Und der test:
Code:
<?php
   include("Contact.php");
   include("ContactList.php");

    $Contact = new Contact();
    $ContactList = new ContactList();
    
    $Contact->SetName("Puff");
    $Contact->SetVorname("Michael");
    $ContactList->Add($ContactList);
    $Contact->SetName("Müller");
    $Contact->SetVorname("Karl");
    $ContactList->Add($ContactList);
    $Contact->SetName("Schmidt");
    $Contact->SetVorname("Hans");
    $ContactList->Add($ContactList);
    
    print_r($ContactList);
//    foreach($ContactList as $Contact) {
//       echo $Contact->GetName().", ".$Contact->GetVorname()."<br>";
//    }
?>
print_r gibt mir aus:
Code:
ContactList Object ( [Contact:ContactList:private] =>[List:ContactList:private] => Array ( [0] => ContactList Object *RECURSION* [1] => ContactList Object *RECURSION* [2] => ContactList Object *RECURSION* ) )
Und die auskommentierte Schleife gibt mir gar nichts aus.

Ja, was mache ich da falsch? Ich habe leider keinen Plan.
Michael
Ein Teil meines Codes würde euch verunsichern.
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 16:49 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz