👨‍💻   Marcel  ✌ avatar

Short Hint for Coding : Best-Practice : Implementation a constant Property on PHP

halloworld

Published: 06 Dec 2019 › Updated: 06 Dec 2019Short Hint for Coding : Best-Practice : Implementation a constant Property on PHP

Short Hint for Coding : Best-Practice : Implementation a constant Property on PHP



DQmPiKcYtB7kqiL7JBjL6JuybPbUPxNvxTAkFarMCAP5xZK_1680x8400.jpeg

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

rect4138.png

Leave Short Hint for Coding : Best-Practice : Implementation a constant Property on PHP to:

Written by

Programmieren, Elektronik, Bücher lesen, Plaudern und vieeeeel Kaffee, https://discord.gg/9ffYXvF

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 ✌