If an exception is thrown and its current function scope has no catch block, the exception will "bubble up" the call stack to the calling function until it finds a matching catch block.
منظور از exception will bubble up تو متن بالا چیه؟
سلام و احترام
phrasal verb که شما آورید bubble up معانی مختلفی داره ولی توی این جمله با معنی ‘آشکار شدن’ هستش
امیر صالحی۰۹ اردیبهشت ۱۴۰۰، ۱۷:۰۶
سلام.
یعنی اگر در تابع جاری exception تولید شده مدیریت نشده باشد با توجه به ساختار سلسله مراتبی callstack به زنجیر بالایی منتقل میشود(مثلا تابع بالاتری که این تابع رو صدا زده) و همینطور به فراخوانیهای بالاتر منتقل میشود تا به یک catch برسد. اگر هم این اکسپشن در هیچ کجا مدیریت نشده باشد یک fatal error اتفاق میافتد.
مثال:
<?php
function funcOne() {
try {
funcTwo();
echo 'This will not run!';
} catch(Exception $e) {
echo $e->getMessage();
}
}
function funcTwo() {
funcThree();
}
function funcThree() {
throw new Exception('An exception has occurred!');
}
// funcThree will bubble up to funcTwo, funcTwo will bubble up to funcOne
funcOne();