class Baz
{
public function bar() {
$this->foo();
}
public function foo() {
$backtrace = debug_backtrace();
$stack = array_map(
function($el) {
return "{$el['class']}{$el['type']}{$el['function']}";
},
$backtrace
);
var_dump($stack);
}
}
$t = new Baz;
$t->bar();
/* array(2) {
[0] => string(8) "Baz->foo"
[1] => string(8) "Baz->bar"
} */
$e = count($d) - 1;
$f = false;
$g = 0;
$h = 0;
if ($c < 0) {
$c = -$c;
$f = true;
}
$i = 2 / (2 + $c);
$j = 4 * $i - 2;
for (; $e > 0; $e--) {
$k = $g;
$g = $j * $g - $h + $d[$e];
$h = $k;
}
$l = $i * exp(-$c * $c + 0.5 * ($d[0] + $j * $g) - $h);
return $f ? ($l - 1) : (1 - $l);
$dateTime = new DateTime('2021-05-18T15:30:00.000-04:00');
var_dump($dateTime);
$dateTime->setTimezone(new DateTimeZone('Europe/Moscow'));
var_dump($dateTime);
// object(DateTime)#1 (3) {
// ["date"] => string(26) "2021-05-18 15:30:00.000000"
// ["timezone_type"] => int(1)
// ["timezone"] => string(6) "-04:00"
// }
//object(DateTime)#1 (3) {
// ["date"] => string(26) "2021-05-18 22:30:00.000000"
// ["timezone_type"] => int(3)
// ["timezone"] => string(13) "Europe/Moscow"
//}
$timestamp = strtotime('2021-05-18T15:30:00.000-04:00');
var_dump($timestamp); // int(1621366200)
date_default_timezone_set('Europe/Moscow');
$dateTime = date('c', $timestamp);
var_dump($dateTime); // string(25) "2021-05-18T22:30:00+03:00"
foreach($rates['currency'] as $rate) {
if($rate['from'] === $amountCurrency && $rate['to'] === $targetCurrency) {
$directRate = $rate;
}
if($rate['from'] === $targetCurrency && $rate['to'] === $amountCurrency) {
$reversedRate = $rate;
}
}
Поскольку строки с $rate['from'] === "USD" и $rate['to'] === "RUB" в массиве нету, то $directRate останется равной null.if ($directRate) {
....
}
Этот блок не выполнится, так как в $directRate записан null.if ($reversedRate) { // На эту строку не обращать внимания
if ($reversedRate['operationType'] == 'buy') {
$amountConverted = $reversedRate['value'];
} elseif ($directRate['operationType'] == 'sell') {
$amountConverted = $reversedRate['value'];
}
}
Здесь сработает ветка с $reversedRate['operationType'] == 'buy' и в $amountConverted запишется "75.65".$conversionRate = null;
foreach($rates['currency'] as $rate) {
if (($rate['operationType'] === 'buy' &&
$rate['from'] === $amountCurrency &&
$rate['to'] === $targetCurrency) ||
($rate['operationType'] === 'sell' &&
$rate['from'] === $targetCurrency &&
$rate['to'] === $amountCurrency)
) {
$conversionRate = $rate['value'];
}
}
var_dump($conversionRate);
mysqli::query
Возвращает false в случае неудачи. В случае успешного выполнения запросов SELECT, SHOW, DESCRIBE или EXPLAIN mysqli_query() вернёт объект mysqli_result.
if ($row)
приводится к true, условие выполняется, клиенту возвращается "true". $2y$10$jSAr/RwmjhwioDlJErOk9OQEO7huLz9O6Iuf/udyGbHPiTNuB3Iuy
2y - тип хэша, BCRYPT.$simpleDate = date('m-d');
if ($simpleDate >= '12-20' || $simpleDate <= '01-11') {
...
}
class Config
{
public const LOGOS = [
['from' => '01-01', 'to' => '01-11', 'logo' => 'logo-newyear.png'],
['from' => '04-25', 'to' => '05-03', 'logo' => 'logo-firstmay.png'],
...,
['from' => '12-20', 'to' => '12-31', 'logo' => 'logo-newyear.png']
];
}
...
$simpleDate = date('m-d');
$logoName = 'logo-standard.png';
foreach (Config::LOGOS as $logoDef) {
if ($simpleDate >= $logoDef['from'] && $simpleDate <= $logoDef['to']) {
$logoName = $logoDef['logo'];
}
}
uasort($ar, static fn($a, $b) : int => $a[0] - $b[0]);