<?php
session_start();
function redirectBack($data = null) {
if (isset($data)) {
$_SESSION['answer'] = $data;
} else {
unset($_SESSION['answer']);
}
header('Location: '. $_SERVER['REQUEST_URI']); exit;
}
$login = 'Lane';
$password = 'admin';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (empty($_POST['login']) || empty($_POST['password'])) {
redirectBack("Something is incorrect...");
}
if ($_POST['login'] != $login || $_POST['password'] != $password) {
redirectBack("Something is incorrect...");
}
redirectBack("The authorization went well!");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="styles.css" rel="stylesheet" />
<title>Project - ведение списков</title>
</head>
<body>
<? if (!empty($_SESSION['answer'])) : ?>
<div class="alert alert-warning" role="alert">
<?= $_SESSION['answer']; ?>
</div>
<? endif; ?>
</body>
</html>
Collection of real world database schemas from open-source packages and real-world apps that you can use as inspiration when architecting your app.
class Listing extends Eloquent
{
public function model()
{
return $this->belongsTo('Model', 'model_id');
}
}
class Model extends Eloquent
{
public function manufacturer()
{
return $this->belongsTo('manufacturer');
}
}
class Manufacturer extends Eloquent
{
}
$listings = Listing::with('model.manufacturer')->all();
foreach($listings as $listing) {
echo $listing->model->manufacturer->name;
}
class Listing extends Eloquent
{
public function model()
{
return $this->belongsTo('Model', 'model_id');
}
public function modelManufacturer()
{
return $this->belongsTo('Model', 'model_id')
->join('.......')
->select('manufacturer.*');
}
}
Специальные символы:
* - Соответствует нулю или большему количеству символов.
? - Соответствует ровно одному символу (любому символу).
[...] - Соответствует одному символу из группы. Если первый символ !, то соответствует любому символу, не входящему в группу
\ - Экранирует следующий символ, кроме случаев, когда используется флаг GLOB_NOESCAPE.
foreach (glob("*.txt") as $filename) {
echo "$filename размер " . filesize($filename) . "\n";
}
rename("/tmp/tmp_file.txt", "/home/user/login/docs/my_file.txt");
[SERV_UTF8]
host = serv.site.ru
port = 1433
tds version = 8.0
client charset = UTF-8
$dbh = new PDO("dblib:host=SERV_UTF8;dbname=db", $username, $pw);
class ClientReportController extends Controller
{
private $reportService;
public function __construct(ReportService $service)
{
$this->reportService = $service;
}
public function index(Request $request)
{
$entries = $this->reportService->getTransactionReport($request->input('project'));
// ...
}
public function income(Request $request)
{
$entries = $this->reportService->getIncomeReport($request->input('project'));
// ...
}
}
<a href="https://site.ru/get-file/filename.jpg" download></a>