Created
September 22, 2012 14:04
-
-
Save vojkny/3766259 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Cislo { | |
private $value; | |
public function Cislo($value) { | |
$this->value = $value; | |
} | |
public function getValue() { | |
return $this->value; | |
} | |
public function pricti(Cislo $pricitaneCislo) { | |
$this->value = $this->value + $pricitaneCislo->getValue(); | |
return $this; | |
} | |
public function odecti(Cislo $odecitaneCislo) { | |
$this->value = $this->value + $odecitaneCislo->getValue(); | |
return $this; | |
} | |
} | |
$cislo = new Cislo(32); | |
$druhe = new Cislo(2); | |
$vysledek = $cislo->pricti($druhe); | |
$cislo->pricti($druhe); | |
$cislo->pricti($druhe); | |
$cislo->pricti($druhe); | |
$cislo->pricti($druhe); | |
$cislo->pricti($druhe); | |
$c = 32; | |
$d = 2; | |
$c + $d; | |
$c + $d; | |
$c + $d; | |
$c + $d; | |
$c + $d; | |
$c + $d; | |
echo $vysledek2; | |
$a = "Tohle je retezec"; | |
$b = "Durhy"; | |
$vysledek = $a.$b; | |
$nahradit = str_replace('Tohle', 'Neco jineho', $a); | |
$pozice = strpos($a, 'je'); | |
$vstup = '24'; | |
$vystup = str_pad($vstup, 5, '0', STR_PAD_LEFT); | |
$vystup == '00024'; | |
$vystup = str_pad($vstup, 5, '0', STR_PAD_RIGHT); | |
$vystup == '24000'; | |
trida Retezec | |
+ nahradNecoZa | |
+ pozice | |
+ vyplnPred | |
+ vyplnZa | |
$retezec = new Retezec('Muj retezec'); | |
$retezec->nahradNecoZa('Muj', 'Tvuj'); | |
$retezec->pozice('ret'); | |
$retezec->vyplnPred(40, '_'); | |
echo $retezec->getValue(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment