Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[PHP] OOP | Wert wird nicht auf Attribut gespeichert

Empfohlene Antworten

Veröffentlicht

Hi Leute,

ich habe hier eine klasse geschrieben mit folgender methode:


class row {
var $aFields = array();

function addColumn ( $aNewFields) {
$this->aFields = array_merge( $this->aFields, $aNewFields);
}
}
[/PHP]

mir kommt so vor als wenn das ergebnis der verbindung der beiden arrays "nur" auf einer lokalen variable $this->aFields gespeichert wird, anstatt auf das Attribut!

Warum ist dass so?

wo ist mein fehler

Danke und Gruß,

kills

PS:

wenn ich mir das $this->aFields innerhalb dieser Methode aufrufe, dann habe ich auch die gewollte anzahl von elementen im array, aber wenn ich z.b. innerhalb von addColumn noch eine andere methode aufrufe und in dieser wieder mit einer foreach schleife auf mein $this->aFields zugreife, hat es auf einmal nur die anzahl von elementen des "alten" arrays, nicht die der beiden verbundenen arrays

(ich hoffe das war nicht zu kompliziert :D)

also ich hab da nicht sonderlich ahnung. nennt man glaube ich konstruktor: wie sieht der denn aus? versuchs doch mal so:



class row {
var $aFields;

function row ($irgendwas){
$this->aFields = array();
}


function addColumn ( $aNewFields) {
$this->aFields = array_merge( $this->aFields, $aNewFields);
}
}

[/php]

was du da schreibst hat nix mit dem problem zu tun aber trotzdem danke für die Antwort!

hi,

was ist denn hieraus geworden?

Hi,

der fehler besteht weiterhin

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.