>DansTonCode();

Tous les codes sources "Mais pourquoi ?"page 39

PHP
  3 June, 2014 à 09:22
#213
function isCC($num)
{
    $length = strlen($num);
    $fuck = 0;
    for($i = $length-1; $i>=0; $i--)
    {
        $digit = substr($num, $i, 1);
        if ((($length - $i) % 2) == 0)
        {
            $digit = $digit * 2;
	          if ($digit > 9)
							$digit = $digit - 9;
        }
        $fuck += $digit;
    } 
    return (($fuck % 10) == 0);
}
PHP
  1 June, 2014 à 04:52
#175
// . . .
	return $this->boolean((bool)$data);
}
	
/**
 * Translates between PHP boolean values and Database (faked) boolean values
 *
 * @param mixed $data Value to be translated
 * @return mixed Converted boolean value
 * @access public
 */
	function boolean($data) {
		if ($data === true || $data === false) {
			if ($data === true) {
				return "true";
			}
			return "false";
		} else {
			return !empty($data);
		}
	}