<?php
interface InputFields {
public function show();
public function addStyle(array $styles);
}
class InputEmail implements InputFields {
private $_styles = "styles=\"";
private $_start_tag = "<input type = 'email' ";
private $_end_tag = ">";
public function addStyle(array $styles) {
foreach ($styles as $style => $value){
$this->_styles .= $style . ':' . $value . ';';
}
$this->_styles .= '"';
return $this->_styles;
}
public function show() {
echo $this->_start_tag . $this->_styles . $this->_end_tag . '<br>'. '<br>';
}
}
$input = new InputEmail();
$input->addStyle ([
'width' => '300px',
'border-radius' => '5px',
'border' => '1px solid blue',
'background' => '#fcfcfc',
'padding' => '10px 20px',
]);
$input->show();
// Output: <input type = 'email' styles="width:300px;border-radius:5px;border:1px solid blue;background:#fcfcfc;padding:10px 20px;"><br><br>
$mysqli = new mysqli('yourhost', 'youruser', 'yourpassword', 'yourdb');
if (mysqli_connect_errno()) {
printf("Не удалось подключиться: %s\n", mysqli_connect_error());
exit();
}
printf("Изначальная кодировка: %s\n", $mysqli->character_set_name());
if (!$mysqli->set_charset("utf8")) {
printf("Ошибка при загрузке набора символов utf8: %s\n", $mysqli->error);
exit();
} else {
printf("Установлен текущий набор символов: %s\n", $mysqli->character_set_name());
}
ALTER DATABASE yourdbname CHARACTER SET utf8 COLLATE utf8_general_ci;
\[(.+?)\]