Skip to content

Instantly share code, notes, and snippets.

@vojkny
Created September 22, 2012 14:04
Show Gist options
  • Save vojkny/3766259 to your computer and use it in GitHub Desktop.
Save vojkny/3766259 to your computer and use it in GitHub Desktop.
<?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