php-kilo/test.php

75 lines
1.0 KiB
PHP
Raw Normal View History

2019-11-05 13:50:02 -05:00
<?php declare(strict_types=1);
interface Ifoo {}
abstract class Foo implements Ifoo {
/**
* @param int $a
* @param float $b
* @param array $c
* @param callable $d
* @return string
*/
2019-11-05 13:50:02 -05:00
abstract public function bar(int $a, float $b, array $c, callable $d): string;
protected function doNothing(): void {}
}
/**
* Docblock comment
*/
class FooBar extends Foo implements Ifoo {
public function bar(int $a, float $b, array $c, callable $d): string
{
$cstr = print_r($c, TRUE);
$d();
return "{$a}, ${b}, " . $cstr;
}
private function operations(int $a, int $b): int
{
$this->doNothing();
$c = $a + $b;
$a = $c - $b;
$c = $a * $b;
$b = (int) ($c / $a);
return $c;
}
}
/*
* Multi-line comment
*/
$foobar = new FooBar();
$x = 3;
2019-11-06 13:57:19 -05:00
$y = [
1,
2,
3
];
/*
Heredoc
*/
2019-11-05 13:50:02 -05:00
$sql = <<<SQL
SELECT * FROM "foo" WHERE "bar"='baz' AND id={$x};
SQL;
/* Nowdoc */
2019-11-05 13:50:02 -05:00
$template = <<<'TEMPLATE'
<foo>{x}</foo>
TEMPLATE;
?>
<html lang="en">
<body>
<h1><?= $_SERVER['HTTP_HOST'] ?></h1>
</body>
</html>