aboutsummaryrefslogtreecommitdiffhomepage
path: root/catchline.php
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2023-02-12 19:09:52 +0900
committernsfisis <nsfisis@gmail.com>2023-02-12 20:52:47 +0900
commitae5b7a122f8e24dd38faa476cb3a1ec84f13b564 (patch)
tree4aa1167b52e50e7c0baed5cb34ed37fd6c2a4ec1 /catchline.php
parent09831c67395848379506ca30f284310c9887572b (diff)
downloadphpstudy-149-slides-ae5b7a122f8e24dd38faa476cb3a1ec84f13b564.tar.gz
phpstudy-149-slides-ae5b7a122f8e24dd38faa476cb3a1ec84f13b564.tar.zst
phpstudy-149-slides-ae5b7a122f8e24dd38faa476cb3a1ec84f13b564.zip
スライドを作成
Diffstat (limited to 'catchline.php')
-rw-r--r--catchline.php62
1 files changed, 62 insertions, 0 deletions
diff --git a/catchline.php b/catchline.php
new file mode 100644
index 0000000..058abeb
--- /dev/null
+++ b/catchline.php
@@ -0,0 +1,62 @@
+<?php
+try {
+ f(3);
+} catch (Throwable $e) {
+ while ($e = $e->getPrevious()) printf('%c', $e->getLine() + 23);
+ echo "\n";
+}
+function f(int $i) {
+ if ($i < 0) f();
+ try {
+ match ($i) {
+ 0 => X, // 12行目
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 2 => X, // 49行目
+
+
+
+
+
+
+
+ 1, 3 => X, // 57行目
+ };
+ } finally {
+ f($i - 1);
+ }
+}