Notice: Use of undefined constant ชื่อ - assumed 'ชื่อ' in /path/to/file.php on line ...
Notice: Use of undefined constant รหัส - assumed 'รหัส' in /path/to/file.php on line ... [1]{0}2
[2]{1}3
[3]{2}4
... (infinite loop) ...
[44916]{44915}44917<
Notice: Undefined variable: y in /path/to/file.php on line ...
Notice: Undefined variable: z in /path/to/file.php on line ...
Notice: Undefined variable: z in /path/to/file.php on line ...
Notice: Undefined variable: z in /path/to/file.php on line ... Na = yes,
x = null, y = 1 Notice: Undefined variable: z in /path/to/file.php on line ... , z = null
Required results
Na = 3.793132209153,
x = 2.1415926535898, y = 2, z = 0.7655
program 3
declare(strict_types=1); // the top of file
function greeting(int $lang) {
$word = [];
switch ($lang) {
case "en":
$word[] = "อังกฤษ"; $word[] = "Hello";
break;
case "th":
$word[] = "ไทย"; $word[] = "สวัสดี";
break;
case "ch":
$word[] = "จีน"; $word[] = "你好";
break;
case "jp":
$word[] ="ณี่ปุ่น"; $word[] = "こんにちは";
break;
default:
$word[] = $lang; $word[] = "ยังไม่สนับสนุน";
}
echo "$word[0] : $word[1] <br>";
}
greeting('th');
greeting('ch');
greeting();
greeting('jp');
greeting('kr');
buggy
Fatal error: Uncaught TypeError: Argument 1 passed to greeting() must be of the type integer,
string given, called in /path/to/file.php on line ... and defined in /path/to/file.php:...
Stack trace: #0 /path/to/file.php(...): greeting('th') #1 {main} thrown in
/path/to/file.php on line ...