Hallo.
Ich versuche mich weiter zu bilden und arbeite mich nun in Getter und Setter ein.
Der Vergleich unten gibt mir andauernd nur "Zugriff verweigert" aus.
Kann mir da jmd helfen, da error_reporting(E_ALL) mir auch nichts anzeigt.
Ich versuche mich weiter zu bilden und arbeite mich nun in Getter und Setter ein.
Der Vergleich unten gibt mir andauernd nur "Zugriff verweigert" aus.
Kann mir da jmd helfen, da error_reporting(E_ALL) mir auch nichts anzeigt.
PHP-Code:
<?php
error_reporting(E_ALL);
class Kunde
{
private $kontostand;
private $geheimzahl;
// Methoden
// Setter: Kontostand
public function setKontostand($konto)
{
$this->kontostand = $konto;
//echo "Konto = $konto<br><br>";
}
// Getter: Kontostand
public function getKontostand()
{
echo "Ihr Kontostand ist ";
echo $this->kontostand;
echo " Euro<br>";
}
// Getter: Geheimzahl
public function getGeheimzahl()
{
echo "Ihre Geheimzahl ist ";
echo $this->geheimzahl;
echo "<br>";
}
public function setGeheimzahl($zahl)
{
$this->geheimzahl = $zahl;
//echo "Zahl = $zahl<br><br>";
}
}
$schmitt = new Kunde();
// Kontostand verändern
$schmitt->setKontostand(1000);
// Kontostand ausgeben
$schmitt->getKontostand();
// Geheimzahl verändern
$schmitt->setGeheimzahl(1321);
// Geheimzahl überprüfen
$eingabeausBankingFormular = 1321; // auf 1321 ändern,
// um funktionalität zu überprüfen
if ($schmitt->getGeheimzahl() == $eingabeausBankingFormular)
{
echo "Zugang gewährt!";
}
else
{
echo "Zugang verweigert";
//echo "<br>Ihre Eingabe war: $eingabeausBankingFormular";
}
?>

Kommentar