Created
April 9, 2013 17:57
-
-
Save ThamaraHessel/5347874 to your computer and use it in GitHub Desktop.
Dúvida do Giovani Silveira na comunidade PHPBrasil no G+.
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 | |
//verificação 1 | |
public function setNascimento($data) | |
{ | |
if(date("Y-m-d", strtotime($data)) != $data){ | |
throw new \InvalidArgumentException("Is not a valid date."); | |
} | |
} | |
//verificação 2 | |
public function setNascimento($data) | |
{ | |
$date = explode("-", $data); | |
if(!checkdate($date[1],$date[2],$date[0])){ | |
throw new \InvalidArgumentException("Is not a valid date."); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment