Created
March 11, 2022 08:29
-
-
Save damjes/dae9152d9067d8882c1572237cd88b47 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 Komunikat { | |
private static $komunikaty = []; | |
public $tresc; | |
public $typ; | |
function __construct($tresc, $typ = 'info') { | |
$this->tresc = $tresc; | |
$this->typ = $typ; | |
self::$komunikaty[] = $this; | |
} | |
function wypisz() { | |
$ikona = 'info'; | |
$klasa = 'info'; | |
if($this->typ == 'blad') { | |
$ikona = 'close-o'; | |
$klasa = 'blad'; | |
} | |
?> <div class="komunikat <?php echo $klasa; ?>"> | |
<i class="gg-<?php echo $ikona; ?>"></i> <?php echo $this->tresc; ?> | |
</div> <?php | |
} | |
static function wypiszKomunikaty() { | |
foreach(self::$komunikaty as $komunikat) { | |
$komunikat->wypisz(); | |
} | |
} | |
} | |
new Komunikat('Info'); | |
//setcookie | |
new Komunikat('Nie dziel przez zero', 'blad'); | |
?> | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
<style> | |
.komunikat { | |
width: 100%; | |
box-sizing: border-box; | |
border: 1px solid; | |
border-radius: 5px; | |
margin: 0.5em 0; | |
padding: 0.5em; | |
} | |
.komunikat.info { | |
border-color: green; | |
background-color: #a0ffa0; | |
} | |
.komunikat.blad { | |
border-color: red; | |
background-color: #ffa0a0; | |
} | |
.komunikat i { | |
display: inline-block; | |
vertical-align: bottom; | |
margin-right: 0.2em; | |
} | |
</style> | |
<link href='https://css.gg/css?=|close-o|info' rel='stylesheet'> | |
</head> | |
<body> | |
Hello! | |
<?php Komunikat::wypiszKomunikaty(); ?> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment