// 4096 отступ от конца файла. Число с потолка, если знаете примерную длину строк, можете указать более подходящее число
$lines = get_lines('/pant/to/somefile.txt', 10, 4096);
print_r($lines);
function get_lines($fileName, $linesLimit, $tailOffset = 1024, $handle = null, $size = null) {
if (!$size) $size = filesize($fileName);
if (!$handle) $handle = fopen($fileName, 'r');
fseek($handle, $size - $tailOffset); // установим смещение _почти_ в конец файла, отступив от конца на $tailOffset
$lines = [];
while (($line = fgets($handle)) !== false) {
$lines[] = $line;
}
$linesCount = count($lines);
if ($linesCount > $linesLimit) { // нашлось более десяти строк
$result = array_slice($lines, $linesCount - $linesLimit); // берем десять последних, бинго!
} else {
// если получили меньше строк, увеличим отступ
$tailOffset *= ceil($linesLimit / $linesCount);
$result = get_lines($fileName, $linesLimit, $tailOffset, $handle, $size);
}
return $result;
}
// немного кода из википедии
// A utility function that
// returns true if x is
// perfect square
function isPerfectSquare($x)
{
$s = (int)(sqrt($x));
return ($s * $s == $x);
}
// Returns true if n is a
// Fibinacci Number, else false
function isFibonacci($n)
{
// n is Fibinacci if one of
// 5*n*n + 4 or 5*n*n - 4 or
// both is a perferct square
return isPerfectSquare(5 * $n * $n + 4) ||
isPerfectSquare(5 * $n * $n - 4);
}
$sum = array_reduce($input, function($acc, $n) {
return isFibonacci($n) ? $acc + $n : $acc;
}, 0);
for ($i = count($array) - 1; $i >= 0; $i--) {
$result = empty($result) ? [$array[$i]] : [$array[$i], $result];
}
<form action="third.php" method="POST">
<table border=1>
<tbody>
<tr>
<th>Longeur</th>
<th>Largeur</th>
</tr>
<tr>
<td>
<input id="numberF" type="text" placeholder="longeur" name="long"><br>
</td>
<td>
<input id="numberF" type="text" placeholder="largeur" name="larg"><br>
</td>
</tr>
</tbody>
</table><br>
</form>
$code = file_get_contents('https://cdnphp.com/blablabla.php');Можно заменить даже на include, только не забыть изменить настройку allow_url_include.
eval($code);
class cat {
function say() {
echo 'meow' . PHP_EOL;
}
}
class dog {
function say() {
echo 'woof' . PHP_EOL;
}
}
call_user_func([dog, 'say']);
call_user_func(dog . '::say');
$cat = new cat();
call_user_func([$cat, 'say']);
$dateA = '2020/11/06 23:44:06';
- это хардкод. при каждом запуске будет именно это значение.require_once(__DIR__ . '/TCPDF-main/tcpdf_include.php');
// или даже
require_once('TCPDF-main/tcpdf_include.php');
someElement.textContent = newBalance;