mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 08:58:56 +00:00
Add error handling to basic example.
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@299010 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
87775dd402
commit
5da1c6eac5
1 changed files with 15 additions and 1 deletions
|
@ -94,7 +94,13 @@
|
|||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$date = new DateTime('2000-01-01');
|
||||
try {
|
||||
$date = new DateTime('2000-01-01');
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
echo $date->format('Y-m-d');
|
||||
?>
|
||||
]]>
|
||||
|
@ -104,6 +110,14 @@ echo $date->format('Y-m-d');
|
|||
<![CDATA[
|
||||
<?php
|
||||
$date = date_create('2000-01-01');
|
||||
if (!$date) {
|
||||
$e = date_get_last_errors();
|
||||
foreach ($e['errors'] as $error) {
|
||||
echo "$error\n";
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
|
||||
echo date_format($date, 'Y-m-d');
|
||||
?>
|
||||
]]>
|
||||
|
|
Loading…
Reference in a new issue