我想學習PHP,我剛搬到例外,當我 從終於例外給出了一個錯誤的PHP
http://php.net/manual/en/language.exceptions.php
Example #2 Exception handling with a finally block
嘗試一個例子,我得到一個錯誤
Parse error: syntax error, unexpected '{' in C:\xampp\htdocs\test\filename.php on line 13
<?php
function inverse($x) {
if (!$x) {
throw new Exception('Division by zero.');
}
else return 1/$x;
}
try {
echo inverse(5) . "\n";
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
} finally {
echo "First finally.\n";
}
try {
echo inverse(0) . "\n";
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
} finally {
echo "Second finally.\n";
}
// Continue execution
echo 'Hello World';
您使用PHP 5.5或更高版本? –
您使用的是什麼版本的PHP? – xylar
終於阻止由php 5.5或更高版本支持 – vlcekmi3