SlideShare ist ein Scribd-Unternehmen logo
1 von 6
Rechnen mit PHP
Grundrechenarten +, -, *, / $a++ bedeutet:  $a = $a + 1 $a-- bedeutet:  $a = $a - 1
[object Object],[object Object],[object Object],[object Object],Beispiele $a = 239; $b = 102; $produkt = $a * $b; $summe = $a + $b; echo &quot;$a mit $b multipliziert ergibt $produkt<br />&quot;; echo &quot;$a mit $b addiert ergibt $summe&quot;;
Beispiel mit Array $alterPerson = array(17, 19, 21); $alterGesamt = $alterPerson[0] + $alterPerson[2]; echo &quot;Gemeinsam sind sie $alterGesamt Jahre alt.&quot;;
Ergebnisse runden mit  round() $nettobetrag = 15.96638655; $nettobetragGerundet  =  round($nettobetrag, 2) ; // rundet $nettobetrag auf 2 Nachkommastellen echo &quot;Nach Abzug der Mehrwertsteuer bezahlen Sie $nettobetragGerundet  Euro.&quot;; Ausgabe: Nach Abzug der Mehrwertsteuer bezahlen Sie 15.97 Euro. round($variable, NACHKOMMASTELLEN) rundet eine Variable auf eine beliebige Anzahl Nachkommastellen
Nachkommastellen erzwingen mit  number_format() $nettobetrag = 15.90; $nettobetragNachkomma  =  number_format($nettobetrag, 2, ',', '') ; // erzwingt zwei Nachkommastelle // Ausgabe wird sein: 15.90 (statt 15.9) number_format(zahl, nachkommastellen, 10er, 1000er) erzwingt  nachkommastellen  Nachkommastellen $nettobetrag = 1999.9; $nettobetragNachkomma =  number_format($nettobetrag, 2, ' , ', ' . '); Ausgabe:  1 . 999 , 90

Weitere ähnliche Inhalte

Andere mochten auch

PROGRESS REPORTS
PROGRESS REPORTSPROGRESS REPORTS
PROGRESS REPORTSSyed Wadud
 
Négociation partenariale
Négociation partenarialeNégociation partenariale
Négociation partenarialeGeoParks
 
Probleme LöSen Mit Dem Mind Manager Pro 6
Probleme LöSen Mit Dem Mind Manager Pro 6Probleme LöSen Mit Dem Mind Manager Pro 6
Probleme LöSen Mit Dem Mind Manager Pro 6Thomas Teepe
 
Articulación Sistemica FID
Articulación Sistemica FIDArticulación Sistemica FID
Articulación Sistemica FIDfundafid
 
Was Bibliotheken von Gaming-Communities lernen können
Was Bibliotheken von Gaming-Communities lernen könnenWas Bibliotheken von Gaming-Communities lernen können
Was Bibliotheken von Gaming-Communities lernen könnenChristoph Deeg
 
Die Wärmeversorgung als kommunales Ziel der Energiewende - GBI
Die Wärmeversorgung als kommunales Ziel der Energiewende - GBIDie Wärmeversorgung als kommunales Ziel der Energiewende - GBI
Die Wärmeversorgung als kommunales Ziel der Energiewende - GBIErdwärme Gemeinschaft Bayern e.V.
 
the new digital world explained to the C-suite
the new digital world explained to the C-suitethe new digital world explained to the C-suite
the new digital world explained to the C-suiteBertrand Petit
 
Les moments de charme, ces détails qui font la différence
Les moments de charme, ces détails qui font la différenceLes moments de charme, ces détails qui font la différence
Les moments de charme, ces détails qui font la différenceJean-Francois Lavigne
 
Hymnes orphiques (traduction leconte de lisle) - http://www.projethomere.com
Hymnes orphiques (traduction leconte de lisle) - http://www.projethomere.comHymnes orphiques (traduction leconte de lisle) - http://www.projethomere.com
Hymnes orphiques (traduction leconte de lisle) - http://www.projethomere.comHélène Kémiktsi
 
Post-formation : les meilleures pratiques de gestion-EL Hassan Zine Eddine-Na...
Post-formation : les meilleures pratiques de gestion-EL Hassan Zine Eddine-Na...Post-formation : les meilleures pratiques de gestion-EL Hassan Zine Eddine-Na...
Post-formation : les meilleures pratiques de gestion-EL Hassan Zine Eddine-Na...Nabil Gharib
 
Declaration ted, sexualite
Declaration ted, sexualiteDeclaration ted, sexualite
Declaration ted, sexualiteMarta Montoro
 

Andere mochten auch (13)

PROGRESS REPORTS
PROGRESS REPORTSPROGRESS REPORTS
PROGRESS REPORTS
 
Négociation partenariale
Négociation partenarialeNégociation partenariale
Négociation partenariale
 
Probleme LöSen Mit Dem Mind Manager Pro 6
Probleme LöSen Mit Dem Mind Manager Pro 6Probleme LöSen Mit Dem Mind Manager Pro 6
Probleme LöSen Mit Dem Mind Manager Pro 6
 
Articulación Sistemica FID
Articulación Sistemica FIDArticulación Sistemica FID
Articulación Sistemica FID
 
Was Bibliotheken von Gaming-Communities lernen können
Was Bibliotheken von Gaming-Communities lernen könnenWas Bibliotheken von Gaming-Communities lernen können
Was Bibliotheken von Gaming-Communities lernen können
 
Formato proyecto
Formato proyectoFormato proyecto
Formato proyecto
 
Perú y sus maravillas
Perú y sus maravillasPerú y sus maravillas
Perú y sus maravillas
 
Die Wärmeversorgung als kommunales Ziel der Energiewende - GBI
Die Wärmeversorgung als kommunales Ziel der Energiewende - GBIDie Wärmeversorgung als kommunales Ziel der Energiewende - GBI
Die Wärmeversorgung als kommunales Ziel der Energiewende - GBI
 
the new digital world explained to the C-suite
the new digital world explained to the C-suitethe new digital world explained to the C-suite
the new digital world explained to the C-suite
 
Les moments de charme, ces détails qui font la différence
Les moments de charme, ces détails qui font la différenceLes moments de charme, ces détails qui font la différence
Les moments de charme, ces détails qui font la différence
 
Hymnes orphiques (traduction leconte de lisle) - http://www.projethomere.com
Hymnes orphiques (traduction leconte de lisle) - http://www.projethomere.comHymnes orphiques (traduction leconte de lisle) - http://www.projethomere.com
Hymnes orphiques (traduction leconte de lisle) - http://www.projethomere.com
 
Post-formation : les meilleures pratiques de gestion-EL Hassan Zine Eddine-Na...
Post-formation : les meilleures pratiques de gestion-EL Hassan Zine Eddine-Na...Post-formation : les meilleures pratiques de gestion-EL Hassan Zine Eddine-Na...
Post-formation : les meilleures pratiques de gestion-EL Hassan Zine Eddine-Na...
 
Declaration ted, sexualite
Declaration ted, sexualiteDeclaration ted, sexualite
Declaration ted, sexualite
 

Mehr von lehrerfreund

mySQL - INSERT INTO
mySQL - INSERT INTOmySQL - INSERT INTO
mySQL - INSERT INTOlehrerfreund
 
mySQL - CREATE TABLE
mySQL - CREATE TABLEmySQL - CREATE TABLE
mySQL - CREATE TABLElehrerfreund
 
mySQL - Felddatentypen
mySQL - FelddatentypenmySQL - Felddatentypen
mySQL - Felddatentypenlehrerfreund
 
CSS: Links formatieren
CSS: Links formatierenCSS: Links formatieren
CSS: Links formatierenlehrerfreund
 
CSS: Zweispaltige Layouts
CSS: Zweispaltige LayoutsCSS: Zweispaltige Layouts
CSS: Zweispaltige Layoutslehrerfreund
 
CSS - Externes Stylesheet
CSS - Externes StylesheetCSS - Externes Stylesheet
CSS - Externes Stylesheetlehrerfreund
 
PHP: Variablen entschaerfen
PHP: Variablen entschaerfenPHP: Variablen entschaerfen
PHP: Variablen entschaerfenlehrerfreund
 
PHP: Indiziertes Array
PHP: Indiziertes ArrayPHP: Indiziertes Array
PHP: Indiziertes Arraylehrerfreund
 
PHP: Assoziative Arrays
PHP: Assoziative ArraysPHP: Assoziative Arrays
PHP: Assoziative Arrayslehrerfreund
 
PHP: br und n (new line)
PHP: br und n (new line)PHP: br und n (new line)
PHP: br und n (new line)lehrerfreund
 
PHP: Variablen und Datentypen
PHP: Variablen und DatentypenPHP: Variablen und Datentypen
PHP: Variablen und Datentypenlehrerfreund
 
PHP: echo, kommentare
PHP: echo, kommentarePHP: echo, kommentare
PHP: echo, kommentarelehrerfreund
 

Mehr von lehrerfreund (20)

ERM - Überblick
ERM - ÜberblickERM - Überblick
ERM - Überblick
 
mySQL - INSERT INTO
mySQL - INSERT INTOmySQL - INSERT INTO
mySQL - INSERT INTO
 
mySQL - CREATE TABLE
mySQL - CREATE TABLEmySQL - CREATE TABLE
mySQL - CREATE TABLE
 
mySQL - SELECT
mySQL - SELECTmySQL - SELECT
mySQL - SELECT
 
mySQL - Felddatentypen
mySQL - FelddatentypenmySQL - Felddatentypen
mySQL - Felddatentypen
 
CSS: Links formatieren
CSS: Links formatierenCSS: Links formatieren
CSS: Links formatieren
 
CSS: Zweispaltige Layouts
CSS: Zweispaltige LayoutsCSS: Zweispaltige Layouts
CSS: Zweispaltige Layouts
 
CSS - Externes Stylesheet
CSS - Externes StylesheetCSS - Externes Stylesheet
CSS - Externes Stylesheet
 
PHP: foreach
PHP: foreachPHP: foreach
PHP: foreach
 
PHP: Switch
PHP: SwitchPHP: Switch
PHP: Switch
 
PHP: Variablen entschaerfen
PHP: Variablen entschaerfenPHP: Variablen entschaerfen
PHP: Variablen entschaerfen
 
PHP: exit
PHP: exitPHP: exit
PHP: exit
 
PHP: isset
PHP: issetPHP: isset
PHP: isset
 
PHP: if-else
PHP: if-elsePHP: if-else
PHP: if-else
 
PHP: Indiziertes Array
PHP: Indiziertes ArrayPHP: Indiziertes Array
PHP: Indiziertes Array
 
PHP: Assoziative Arrays
PHP: Assoziative ArraysPHP: Assoziative Arrays
PHP: Assoziative Arrays
 
PHP: br und n (new line)
PHP: br und n (new line)PHP: br und n (new line)
PHP: br und n (new line)
 
PHP: Variablen und Datentypen
PHP: Variablen und DatentypenPHP: Variablen und Datentypen
PHP: Variablen und Datentypen
 
PHP: echo, kommentare
PHP: echo, kommentarePHP: echo, kommentare
PHP: echo, kommentare
 
CSS: div und span
CSS: div und spanCSS: div und span
CSS: div und span
 

PHP: Rechnen mit PHP

  • 2. Grundrechenarten +, -, *, / $a++ bedeutet: $a = $a + 1 $a-- bedeutet: $a = $a - 1
  • 3.
  • 4. Beispiel mit Array $alterPerson = array(17, 19, 21); $alterGesamt = $alterPerson[0] + $alterPerson[2]; echo &quot;Gemeinsam sind sie $alterGesamt Jahre alt.&quot;;
  • 5. Ergebnisse runden mit round() $nettobetrag = 15.96638655; $nettobetragGerundet = round($nettobetrag, 2) ; // rundet $nettobetrag auf 2 Nachkommastellen echo &quot;Nach Abzug der Mehrwertsteuer bezahlen Sie $nettobetragGerundet Euro.&quot;; Ausgabe: Nach Abzug der Mehrwertsteuer bezahlen Sie 15.97 Euro. round($variable, NACHKOMMASTELLEN) rundet eine Variable auf eine beliebige Anzahl Nachkommastellen
  • 6. Nachkommastellen erzwingen mit number_format() $nettobetrag = 15.90; $nettobetragNachkomma = number_format($nettobetrag, 2, ',', '') ; // erzwingt zwei Nachkommastelle // Ausgabe wird sein: 15.90 (statt 15.9) number_format(zahl, nachkommastellen, 10er, 1000er) erzwingt nachkommastellen Nachkommastellen $nettobetrag = 1999.9; $nettobetragNachkomma = number_format($nettobetrag, 2, ' , ', ' . '); Ausgabe: 1 . 999 , 90