output.php
· 970 B · PHP
Bruto
<?php
function output(...$data)
{
$result = [];
foreach ($data as $something) {
if ($something instanceof Illuminate\Support\Collection) {
$something = $something->toArray();
}
if (is_array($something)) {
$something = var_export($something, true);
}
if (empty($something)) {
$something = '';
}
if (is_object($something)) {
if (method_exists($something, 'toArray')) {
$something = $something->toArray();
} elseif (method_exists($something, 'jsonSerialize')) {
$something = $something->jsonSerialize();
} else {
$something = var_export($something, true);
}
}
$result[] = $something;
}
file_put_contents(
'test_' . date('d.m.Y') . '.log',
'[' . date('H:i:s') . '] ' .
implode(' ', $result) . PHP_EOL,
FILE_APPEND
);
}
1 | <?php |
2 | function output(...$data) |
3 | { |
4 | $result = []; |
5 | foreach ($data as $something) { |
6 | if ($something instanceof Illuminate\Support\Collection) { |
7 | $something = $something->toArray(); |
8 | } |
9 | if (is_array($something)) { |
10 | $something = var_export($something, true); |
11 | } |
12 | if (empty($something)) { |
13 | $something = ''; |
14 | } |
15 | if (is_object($something)) { |
16 | if (method_exists($something, 'toArray')) { |
17 | $something = $something->toArray(); |
18 | } elseif (method_exists($something, 'jsonSerialize')) { |
19 | $something = $something->jsonSerialize(); |
20 | } else { |
21 | $something = var_export($something, true); |
22 | } |
23 | } |
24 | $result[] = $something; |
25 | } |
26 | file_put_contents( |
27 | 'test_' . date('d.m.Y') . '.log', |
28 | '[' . date('H:i:s') . '] ' . |
29 | implode(' ', $result) . PHP_EOL, |
30 | FILE_APPEND |
31 | ); |
32 | } |