PHP Classes

File: examples/example_2.php

Recommend this page to a friend!
  Classes of Leo Daidone   PHP Sanitize Class   examples/example_2.php   Download  
File: examples/example_2.php
Role: Example script
Content type: text/plain
Description: example2
Class: PHP Sanitize Class
Validate and sanitize string values
Author: By
Last change: Update of examples/example_2.php
Date: 9 months ago
Size: 943 bytes
 

Contents

Class file image Download
<?php
/**
 * Created by PhpStorm.
 * User: leodaido
 * Date: 1/19/15
 * Time: 6:32 PM
 */

require_once(dirname(__FILE__).'/../ClassLoader.php');
ClassLoader::Register();
$base_path = dirname(__FILE__).'/../';

ClassLoader::Load('PHPSanitizer', $base_path);

$sanitizer = PHPSanitizer::getInstance();
$sanitizer->setType(PHPSanitizer::CUSTOM, 'Email', dirname(__FILE__).'/factories/');

$valid_email = "leodaido@gmail.com";
$invalid_email = "some_invalid&email@domain.com,";

echo
"Valid email: $valid_email \n";
echo
"===========================================\n";
echo
"Is valid: ";
echo (
$sanitizer->validate($valid_email)) ? "Si\n" :"No\n";
echo
"Cleaned:".$sanitizer->cleanup($valid_email)."\n\n\n";
echo
"Invalid email: $invalid_email \n";
echo
"===========================================\n";
echo
"Is valid: ";
echo (
$sanitizer->validate($invalid_email)) ? "Si\n" :"No\n";
echo
"Cleaned:".$sanitizer->cleanup($invalid_email)."\n\n\n";