Short Hint for Coding : Best-Practice : Implementation a constant Property on PHP
Implementation a constant Property on PHP
PHP-Klassen bieten das Konzept von Konstantenzuweisungen nicht über Klassenmethoden an. Es gibt aber Wege,
ein Final auf Properties zu erzeugen.
Die Umsetzung in PHP ist wie folgt möglich:
Beispiel:
/**
* @param string $pass
*
* @return $this
*/
public function setfinal_pass( $pass ){
( $this -> pass !== NULL ) ?:$this -> pass = $pass;
return $this;
}
Die setfinal_pass-Methode prüft, ob der Wert von pass schon übergeben wurde.
Im Erfolgsfall passiert einfach Nichts. Wenn der Wert von pass noch NULL besitzt
kann pass parametrisiert werden.
NULL selber steht aber dann nicht mehr als WERT zur Verfügung.
#webdevelopment #code #coding #dev #development #programming
#codedesign #codereview #cleancode #steemit #utopian-io
#technology #science #deutsch #deutschland #german #germany
#orginal #originalworks #diy #php #php5 #php7 #oop #ood
#webserver #webdev #practice #mail #www #web #final #patterns
Leave Short Hint for Coding : Best-Practice : Implementation a constant Property on PHP to:
Read more #deutsch posts
Best Posts From 👨💻 Marcel ✌
We have not curated any of halloworld's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From 👨💻 Marcel ✌
- Short Code : Schnellvorlage für PHP mit fertigen autoloader für Klassen nach PSR-4 Standard
- Short Hint for Coding : Best-Practice : ISTEIN Prinzipien für OOP Vererbungshierachien
- Short Hint for Coding : Best-Practice : Implementation a constant Property on PHP
- Short Hint for Coding : Best-Practice : OOP : Vererbung bestimmen
- Short Hint for Coding : Best-Practice bei Beispiel-eMail und -Domainnamen
- Arrays als Objekte nutzen mit der ArrayObject-Klasse
- Verfügbarkeit von PHP 5.6.40 Update 2019
- Weltweit ist in der Wirtschaft Betrug die Regel - Beispiel eBay
- Werbetafeln unter der Hitze dieses Jahr ausgefallen - Zum Glück - Dinge die die Welt nicht braucht
- Vorzüge vom MD5-Hash - Verzeichnisse Organisieren mit Milliarden von Dateien