Hallo allemaal,

Ik worstel een beetje met het volgende. Ik heb een klasse Ticket. In deze klasse staan een aantal velden met de bijbehorende getters & setters. Zo staat er ook een veld genaamd priority. Dit veld mag alleen de waarde hebben van 1 van de 3 static variabelen in deze klasse $PRIORITY_LOW, $PRIORITY_MEDIUM of $PRIORITY_HIGH. Alleen als ik deze variabelen in de setter gebruik krijg ik de volgende fout:
Fatal error: Undefined class constant 'priority_low' in C:\wamp\www\RoyalPink\index.php on line 20

terwijl naar mijn idee de vatiabele wel defined is.
hieronder de code voor een beter zicht

Ticket.php

<?php

/**
 * @author Bert Sinnema
 * @project RoyalPink 
 * @copyright 2008
 * @description Ticket class
 */

	class Ticket{
		
		private  $className = "Ticket";
		
		static $PRIORITY_LOW = 1;
		static $PRIORITY_MEDIUM = 2;
		static $PRIORITY_HIGH = 3;
		
		private $id;
		private $title;
		private $description;
		private static $priority = 1;
		private $date;
		private $time;
		private $customer;
		
		
			function getId() {
				return $this->id; }
			
			function setId($id) {
				$this->id = $id; }
				
			function getTitle() {
				return $this->title; }
			
			function setTitle($title){
				$this->title = $title;					}
				
			function getDescription(){
				return $this->description;				}
			
			function setDescription($description){
				$this->description = $description;		}						
			
			static function getPriority(){
				return $this->priority;					}
			
			static function setPriority($priority){
				$this->priority = $priority;			}		
			
			function getDate(){
				return $this->date;		}
			
			function setDate($date){
				$this->date = $date;		}		
			
			function getTime(){
				return $this->time;		}
			
			function setTime($time){
				$this->time = $time;		}
				
			function getCustomer(){
				return $this->customer;		}
			
			function setCustomer($customer){
				$this->customer = $customer;		}				
						
			function getClassName(){
				return $this->className;
			}
			
			function printObject(){
				print($this->className ."(" . $this->id . ")". ": " . $this->title . " | " . $this->description . " | " . $this->priority  );
			}
	}

?>



En de test.php


<?php

/**
 * @author Bert Sinnema
 * @project RoyalPink 
 * @copyright 2008
 * @description Test
 */

include("model\Ticket.php");

$ticket1 = new Ticket();
$ticket1->setId(10);
$ticket1->setTitle("Test ticket");
$ticket1->setDescription("Blaat");
$ticket1->setPriority(Ticket::PRIORITY_HIGH);

$ticket1->printObject();



?>
Waarom vraag je precies, exact hetzelfde als hier.
Bump je ofzo?

Reageren