Originariamente inviato da albx87
Se questo è solo un esempio e nel tuo codice originale maiuscole e minuscole sono rispettate, forse è meglio se posti il tuo codice...magari c'è qualche errore che sfugge


ECCO QUI...

codice:
//__________VERIFICA TESTO__________//


class Verifica_Testo{
	
	public $Obbligatorio = TRUE;      // Se il Campo è Obbligatorio o No, di Default è TRUE
	public $Testo;                    // Il Testo da Verificare
	public $Errore;                   // La descrizione dell' Errore
	public $LunghezzaMin;             // Lunghezza di Caratteri Minima
	public $LunghezzaMax;             // Lunghezza di Caratteri Massima
	
	
	
	private function Obbligatorio_Lunghezza(){
		
		//Verifico se è Obbligatorio
		if($this->Obbligatorio){
			if(empty($this->Testo)){
			    $this->Errore = 'Campo Obbligatorio';
			    GestoreErrori::$Errore = FALSE;
			    return FALSE;
			}
		}
		
		//Verifico La Lunghezza Massima Testo
		if(!empty($this->LunghezzaMax)){
		   if(strlen($this->Testo) > $this->LunghezzaMax){
			   $this->Errore = 'Testo Troppo Lungo, Massimo '.$this->LunghezzaMax.' Caratteri';
			   GestoreErrori::$Errore = FALSE;
			   return FALSE;
		   }
		}
		
	    //Verifico La Lunghezza Minima Testo
		if(!empty($this->LunghezzaMin)){
		   if(strlen($this->Testo) < $this->LunghezzaMin){
			   $this->Errore = 'Testo Troppo Corto, Minimo '.$this->LunghezzaMin.' Caratteri';
			   GestoreErrori::$Errore = FALSE;
			   return FALSE;
		   }
		}
		
		return TRUE;
	}
	
	
	
	public function Verifica_Username(){
		
		//Verifico L' Obbligatorietà e la Lunghezza
		if(!$this->Obbligatorio_Lunghezza()){
			GestoreErrori::$Errore = FALSE;
			return;				
		}
		
		// L' Username puo contenere soltanto Lettere Numeri Trattini e Tratini Bassi
		if(!preg_match('/^[a-z0-9-_]{0,}$/i', $this->Testo)){
			$this->Errore = 'Formato Errato';
			GestoreErrori::$Errore = FALSE;
			return;			
		}
				
	}
	
	
	public function Verifica_Email(){
		
		//Verifico L' Obbligatorietà e la Lunghezza
		if(!$this->Obbligatorio_Lunghezza()){
			GestoreErrori::$Errore = FALSE;
			return;				
		}
		
		//Verifico la Email
        if(!filter_var($this->Testo, FILTER_VALIDATE_EMAIL)){
        	$this->Errore = 'Inserisci una Email Corretta';
			GestoreErrori::$Errore = FALSE;
			return;	
        }
				
	}
	
	
	public function Verifica_Link(){
		
		//Verifico L' Obbligatorietà e la Lunghezza
		if(!$this->Obbligatorio_Lunghezza()){
			GestoreErrori::$Errore = FALSE;
			return;				
		}
		
		// L' Username puo contenere soltanto Lettere Numeri Trattini e Tratini Bassi
		if(!preg_match('/^(http:\/\/)+[a-z0-9\-\.]+\.[a-z]{2,4}$/', $this->Testo)){
			$this->Errore = 'Formato Errato';
			GestoreErrori::$Errore = FALSE;
			return;			
		}
				
	}


	public function Verifica_Testo(){
		
		//Verifico L' Obbligatorietà e la Lunghezza
		if(!$this->Obbligatorio_Lunghezza()){
			GestoreErrori::$Errore = FALSE;
			return;				
		}
		
				
	}
		
}