Location: PHPKode > scripts > Shopping basket with MySQL connection > shopping-basket-with-mysql-connection/read_credit_validation_class.txt
  The credit_card class provides methods for cleaning, validating and   
     identifying the type of credit card number.         
                                                                           
     credit_card::clean_no() method                                        
     ------------------------------                                        
     Strips all non-numeric characters from the passed value and returns   
     an integer.  This method is called by the other methods in the        
     credit_card class.                                                    
                                                                           
     USAGE EXAMPLE:                                                        
     $cc_no ="5454 5454 5454 5454"; // Has spaces for readability          
     $cleaned_cc_no = credit_card::clean_no ($cc_no);                      
     print $cleaned_cc_no; // Displays 5454545454545454                    
                                                                           
     credit_card::identify() method                                        
     ------------------------------                                        
     Finds the type of credit card (Mastercard, Visa, etc...) based on     
     the length and format of the credit card number.  The method can      
     identify American Express, Diners Club/Carte Blanche, Discover,       
     enRoute, JCB, Mastercard and Visa cards.                              
                                                                           
     USAGE EXAMPLE:                                                        
     $cc_no ="5454 5454 5454 5454";                                        
     print credit_card::identify ($cc_no); // Returns "Mastercard"         
                                                                           
     credit_card::validate() method                                        
     ------------------------------                                        
     Validate a credit card number using the LUHN formula (mod 10).        
     Note that many other kinds of card and account numbers are based on   
     the LUHN algorith - including Canadian Social Insurance Numbers.      
                                                                           
     USAGE EXAMPLE:                                                        
     $cc_no ="5454 5454 5454 5454";                                        
     print credit_card::validate ($cc_no); // Returns TRUE                 
                                                                           
     credit_card::check() method                                           
     ---------------------------                                           
     The check() method validates and identifies a credit card, returning  
     an array. Indexes 0 and 'valid' will contain TRUE if the card number  
     is valid (FALSE if it isn't), while indexes 1 and 'type' will         
     the type of card (if known). The presence of the numeric keys allows  
     the method to be used with the list() function.                       
                                                                           
     USAGE EXAMPLE:                                                        
     $cc_no ="4111 1111 1111 1111";                                        
     list ($valid, $type) = credit_card::check ($cc_no);                   
     print $valid; // Displays 1 (TRUE)                                    
     print $type;  // Displays "Visa"                                 
Return current item: Shopping basket with MySQL connection