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 | |
namespace App\Http\Controllers; | |
use Illuminate\Http\Request; | |
use App\Models\News; | |
class NewsController extends Controller | |
{ | |
public function index() | |
{ | |
$news = (new News)->getAll(); | |
return view('news', compact('news')); |
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 | |
namespace App\Models; | |
use Illuminate\Support\Facades\DB; | |
class ModelBaseFunction { | |
private $table_name = 'users'; | |
public function getAllUsers(){ |
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 | |
namespace App\Http\Controllers; | |
use Illuminate\Http\Request; | |
class FormController extends Controller | |
{ | |
public function formUser(Request $request) | |
{ |
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 Database{ | |
public $isConn; | |
protected $data; | |
public function __construct($username = "root", $password = "", $host = "127.0.0.1", $dbname = "test", $options = []){ | |
$this->isConn = TRUE; | |
$this->data = new PDO("mysql:host=$host;dbname=$dbname;charset=utf8", $username, $password, $options); | |
$this->data->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | |
$this->data->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); |
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 | |
include 'Database.php'; | |
class Auth { | |
protected $pdo; | |
public function __construct(){ | |
$db = new Database(); | |
$db->baseConfig(); | |
$this->pdo = $db->pdo; | |
} | |
public function login($login, $password){ |
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
<!-- ДОМАШНЕЕ ЗАДАНИЕ | |
#необходимо написать класс по работе с датами со следующими методами | |
#-найти разницу дат, вернуть разницу в формате timestamp | |
#-формат timestamp преобразовать в количество дней (целое число) | |
#-вернуть нужный формат даты (формат задается свойством объекта) на входе дата в формате timestamp | |
#-вернуть словом день недели от заданной даты | |
#-вернуть словом месяц от заданной даты | |
#-определить является ли заданный год высокосным (вернуть true/false) | |
#-преобразовать любой заданный вариант даты в нужный формат, который задан в свойстве класса --> |
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 | |
function square($a){ | |
return $a * $a; | |
} | |
echo 'Квадрат равен: '.square(7).'<br>'; | |
?> | |
<?php |
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
<form action="upload.php" method="POST" enctype="multipart/form-data" target="frame"> | |
<input type="file" name="file"><br><br> | |
<input type="file" name="file1"><br><br> | |
<input type="submit" value="Отправить"> | |
</form> | |
<iframe name = "frame" id="frame" style="width:1000px; height:700px"></iframe> |
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
<!-- Спросите у пользователя имя с помощью формы. Сделайте чекбокс: если он отмечен, то поприветствуйте пользователя, если не отмечен - попрощайтесь с пользователем. --> | |
<form action="" method="POST"> | |
<input type="text" name="name" placeholder="Имя"> | |
<input type="hidden" name="checkbox" value="0"> | |
<input type="checkbox" name="checkbox" value="1"> | |
<input type="submit"> | |
</form> | |
<?php | |
if (isset($_POST['name']) && $_POST['checkbox'] == 1){ |
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
<html> | |
<head> | |
<style> | |
.error{ | |
border:1px solid red; | |
} | |
input{ | |
width: 300px; | |
font-size: 13px; |
NewerOlder