<?php
function date_period_grid($start, $end)
{
$start = new DateTime($start);
$end = new DateTime($end);
$interval = $end->diff($start);
$days = $interval->days;
$months = $interval->y * 12 + $interval->m;
$years = intval($end->format('Y')) - intval($start->format('Y'));
if ($years > 1) {
$period = new DatePeriod($start, new DateInterval('P1Y'), $years);
$format = 'Y';
} elseif ($months > 1) {
$period = new DatePeriod($start, new DateInterval('P1M'), $months);
$format = 'm.Y';
} else {
$period = new DatePeriod($start, new DateInterval('P1D'), $days);
$format = 'd.m.Y';
}
$result = [];
foreach ($period as $date) {
$result[] = $date->format($format);
}
return $result;
}
date_period_grid('2012-07-01', '2015-11-01');
// => ['2012', '2013', '2014', '2015']
date_period_grid('2015-01-01', '2015-11-01');
// => ['01.2015', '02.2015', ..., '11.2015']
date_period_grid('2015-10-01', '2015-11-01');
// => ['01.10.2015', '02.10.2015', ..., '01.11.2015']
jQuery 2.x has the same API as jQuery 1.x, but does not support Internet Explorer 6, 7, or 8. <...> Since IE 8 is still relatively common, we recommend using the 1.x version unless you are certain no IE 6/7/8 users are visiting the site. jquery.com/download
namespace N1
{
class C1 { }
class C2
{
public $c1;
static protected $ns = __NAMESPACE__;
public function __construct()
{
$classname = static::$ns . '\\C1';
$this->c1 = new $classname;
}
}
}
namespace N2
{
class C1 extends \N1\C1 { }
class C2 extends \N1\C2
{
static protected $ns = __NAMESPACE__;
}
}
namespace N1
{
class C1 { }
class C2
{
public $c1;
public function __construct()
{
$r = new \ReflectionObject($this);
$classname = $r->getNamespaceName() . '\\C1';
$this->c1 = new $classname;
}
}
}
namespace N2
{
class C1 extends \N1\C1 { }
class C2 extends \N1\C2 { }
}
if (!empty($errors)) {
return [
'data' => $errors,
'status' => 'error',
'message' => $message,
];
}
return [
'data' => $data,
'status' => 'success',
'message' => 'Done',
];
$status = 'success';
$message = 'Done';
// ...
if (!empty($errors)) {
$data = $errors;
$status = 'error';
}
return [
'data' => $data,
'status' => $status,
'message' => $message,
];
<div id="footer">
<p>© Дизайн - собственность Перескокова Юрия</p>
<p>© CMS - собственность Перескокова Юрия</p>
</div>
class Get_Set_DB_Class
{
public function ConnectForDB()
{
$mysqli = new mysqli("mysql.0hosting.me","u509998950_pers","13071992","u509998950_blog");
return $mysqli;
}
public function Close($mysqli)
{
$mysqli->close();
}
}
$Connect = new Get_Set_DB_Class();
$data = array_filter($data, function ($item) {
return ($item == 1);
});
Когда использовать htmlentities, а когда htmlspecialchars?