Last active
April 18, 2017 06:12
-
-
Save jeavila/1de1334b226f8f9418725da3c9ec5777 to your computer and use it in GitHub Desktop.
Lanzamiento de una excepción.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function inverso($x) | |
{ | |
if (!$x) { | |
// Se crea un objeto de tipo Exception, que será lanzado | |
// para que en otro lado pueda controlarse | |
throw new Exception ('División por cero.'); | |
} | |
return 1 / $x; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment