PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Closed Thread
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 18th, 2013, 11:31 AM
mc1392 mc1392 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 2 mc1392 User rank is Corporal (100 - 500 Reputation Level)mc1392 User rank is Corporal (100 - 500 Reputation Level)mc1392 User rank is Corporal (100 - 500 Reputation Level)mc1392 User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 13 m 50 sec
Reputation Power: 0
PHP-OOP - Fatal error: Cannot redeclare class AbstractClass

I have an abstract class:

Code:
abstract class BaseValidator{
	protected $msgs = array();
	protected $params = array();
	
	abstract protected function isValid($value);
	
	public function __contruct($_params){
		$this->params = $_params;
	}
	
	public function getMessages(){
		return $this->msgs;
	}
	
}



I have some classes extending this class:

Code:
<?php
require 'BaseValidator.php';

class PasswordValidator extends BaseValidator{
	public function isValid($val=null){
		if($val == null){
			$val = $this->params['value'];
		}
		
		if(strlen($val)<$this->params['minlength']){
			array_push($msgs, 'Password length is too short. Password must be at least 8 characters.');
		}
		
		if(!StringUtil::isAlphabetic($val)){
			array_push($msgs, 'Password can only contain characters in the alphabet. No special characters (@#$%^&*()!) are allowed.');
		}
		
		return count($this->msgs) > 0 ? false : true;
	}
}
?>


I have a form processing page that uses them:

Code:
$passwordValidationObject = new PasswordValidator(array('minlength'=>6,'value'=>$password,'required'=>true));
	if(!$passwordValidationObject->isValid()){
		echo implode('<br/>',$passwordValidationObject->getMessages());
	}


I keep getting this error:
Quote:
Fatal error: Cannot redeclare class BaseValidator in BaseValidator.php on line 4


how can i get around this error?
If I remove the require_once BaseValidator, of course, it doesn't work either.

Reply With Quote
  #2  
Old January 18th, 2013, 11:38 AM
mc1392 mc1392 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 2 mc1392 User rank is Corporal (100 - 500 Reputation Level)mc1392 User rank is Corporal (100 - 500 Reputation Level)mc1392 User rank is Corporal (100 - 500 Reputation Level)mc1392 User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 13 m 50 sec
Reputation Power: 0
the problem was I had to use require_once!
Comments on this post
ManiacDan agrees: Yep

Reply With Quote
Closed Thread

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > PHP-OOP - Fatal error: Cannot redeclare class AbstractClass

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap