Foutmelding "Accessing static property Registry::$vars as non static"

Status
Niet open voor verdere reacties.

timmb

Gebruiker
Lid geworden
8 jan 2013
Berichten
53
Hallo ,

Ik hoop dat jullie kunnen helpen.
Ik krijg de volgende foutmeldingen op mijn site:

Strict Standards: Accessing static property Registry::$vars as non static in /home/timievz/domains/domeinnaam.nl/public_html/classes/registry.php on line 9

Strict Standards: Accessing static property Registry::$vars as non static in /home/timievz/domains/domeinnaam.nl/public_html/classes/registry.php on line 13

Strict Standards: Accessing static property Registry::$vars as non static in /home/timievz/domains/domeinnaam.nl/public_html/classes/registry.php on line 19

Strict Standards: Accessing static property Registry::$vars as non static in /home/timievz/domains/domeinnaam.nl/public_html/classes/registry.php on line 23

Strict Standards: Only variables should be passed by reference in /home/timievz/domains/domeinnaam.nl/public_html/classes/template.php on line 20

Strict Standards: Only variables should be passed by reference in /home/timievz/domains/domeinnaam.nl/public_html/classes/template.php on line 20

Strict Standards: Accessing static property Registry::$vars as non static in /home/timievz/domains/domeinnaam.nl/public_html/classes/registry.php on line 31

het enige wat ik hier uit kan lezen is dat de foutmeldingen ontstaan in registry.php en template.php


Registry.php
Code:
<?php
Class Registry extends ArrayObject {
	static private $vars = array();

	function __construct() {
	}

	function set($key, $var) {
		if (isset($this->vars[$key]) == true) {
			throw new Exception('Unable to set var `' . $key . '`. Already set.');
		}

		$this->vars[$key] = $var;

		return true;
	}

	function get($key) {
		if (isset($this->vars[$key]) == false) {
			return null;
		}

		return $this->vars[$key];
	}

	function remove($var) {
		unset($this->vars[$key]);
	}

	function offsetExists($offset) {
		return isset($this->vars[$offset]);
	}

	function offsetGet($offset) {
		return $this->get($offset);
	}

	function offsetSet($offset, $value) {
		$this->set($offset, $value);
	}

	function offsetUnset($offset) {
		unset($this->vars[$offset]);
	}
}
?>

template.php
Code:
<?php
class Template 
{
	var $sContent;
	var $sBlocks = array ();
	var $sBuffer = array ();
	var $errors = array ();
	var $sScript = 1;

	function __construct($registry) {
		$this->r = $registry;
	}

	function define ($sFile = array (), $sMap = NULL)
	{
        	foreach ($sFile AS $content) {
     		 		$sPad = site_path . 'views' . DIRSEP . $content;

            		if($sBestand = @fopen ($sPad, "r")) {
                		$sNaam = end (explode ('/', $sPad));

                		$this->sContent [$sNaam] = fread($sBestand, @filesize($sPad));
                		$this->sBuffer [$sNaam] = array ();
               			$this->sBlocks [$sNaam] = array ();

                		$this->Load_Blocks ($sNaam);
                		fclose ($sBestand);
            		}
            		else $this->errors [] = 'Dit template-bestand kon niet ingeladen worden.';
		}
		$this->r['menu']->Menu ();
	}

	function Load_Blocks ($sBestand) 
	{
		## ROOT blocks vinden
		preg_match_all ("/<block ([\/\\.:\s@a-zA-Z_0-9]*)>(.*?)<\/block \\1>/is", $this->sContent [$sBestand], $sROOT);
		for ($i = 0; $i < count ($sROOT[0]); $i++)
		{
			## In this->blocks opslaan
			$this->sBlocks [$sBestand] ['ROOT_'.$sROOT[1][$i]] = $sROOT[2][$i];

			## Zoeken naar nested-blocks in dit ROOT-block
			if(preg_match_all ("/<block ([\/\\.:\s@a-zA-Z_0-9]*)>(.*?)<\/block \\1>/is", $sROOT[2][$i], $sNested)) 
			{
				for ($y = 0; $y < count ($sNested[0]); $y++) 
				{
					## In this->blocks opslaan
					$this->sBlocks [$sBestand] [$sNested[1][$y]] = $sNested[2][$y];

					## Dit block replacen met {blocknaam} in het ROOT-block
					$this->sBlocks [$sBestand] ['ROOT_'.$sROOT[1][$i]] = preg_replace ("/<block (".$sNested[1][$y]."*)>(.*?)<\/block \\1>/is", "{".$sNested[1][$y]."}", $this->sBlocks [$sBestand] ['ROOT_'.$sROOT[1][$i]]);

					## Zoeken naar nested-blocks in dit nested-block
					if(preg_match_all ("/<block ([\/\\.:\s@a-zA-Z0-9_]*)>(.*?)<\/block \\1>/is", $sNested[2][$y], $sInnested)) 
					{
						for ($a = 0; $a < count ($sInnested[0]); $a++) 
						{
							## In this->blocks opslaan
							$this->sBlocks [$sBestand] [$sInnested[1][$a]] = $sInnested[2][$a];

							## Dit block replacen met {blocknaam} in het nested-block
							$this->sBlocks [$sBestand] [$sNested[1][$y]] = preg_replace ("/<block (".$sInnested[1][$a]."*)>(.*?)<\/block \\1>/is", "{".$sInnested[1][$a]."}", $this->sBlocks [$sBestand] [$sNested[1][$y]]);

						}
					}
				}
			}
		}
		$this->sBuffer = $this->sBlocks; // Ipv heel het traject ook met buffer te doorlopen gewoon dit!
	}

	function Assign ($sBlock, $sAssign, $sValue) 
	{
		foreach ($this->sBlocks AS $key => $content)
		{
			$sBlock = (isset($this->sBlocks[$key]['ROOT_'.$sBlock]) ? 'ROOT_'.$sBlock : $sBlock);
			if(isset($this->sBlocks[$key][$sBlock])) {
				if (preg_match ("/<string ".$sAssign.">/i", $this->sBlocks[$key][$sBlock])) 
					$this->sBlocks[$key][$sBlock] = str_replace ("<string ".$sAssign.">", $sValue, $this->sBlocks[$key][$sBlock]);
			}
		}
	}

	function Assign_Global ($sAssign, $sValue) {
		$this->sGlobals [strtolower ($sAssign)] = $sValue;
	}

	function check_vars ($sFile, $sBlock, $sKey)
	{
		foreach ($sKey AS $key => $content) {
			if(preg_match_all("/<".$sKey[$key]." (.*?)>/ism", $this->sBlocks[$sFile][$sBlock], $sMatches)) {
				for ($i = 0; $i < count ($sMatches[0]); $i++) 
				{
					$value = strtolower ($sMatches[1][$i]);
					$sSleutel = $sMatches[0][$i];

					if ($sKey[$key] == "cookie") $sValue = @$_COOKIE[$value];
					elseif ($sKey[$key] == "session") $sValue = @$_SESSION[$value];
					elseif ($sKey[$key] == "server") $sValue = @$_SERVER[strtoupper($value)];
					elseif ($sKey[$key] == "global") $sValue = @$this->sGlobals[$value];
					elseif ($sKey[$key] == "lang") $sValue = $this->r['lang'][$value];

					$this->sBlocks[$sFile][$sBlock] = str_replace ($sSleutel, $sValue, $this->sBlocks[$sFile][$sBlock]);
				}
			}
		}
	}

	function Parse ($sIn, $sOut = NULL, $sEnd = NULL, $sPagina = NULL) {
		if(!isset ($sOut) && !isset ($sEnd)) {
			$sOut = $sIn;
			$sIn = 'index';
			$sEnd = 'content';
		}

		foreach ($this->sBlocks AS $key => $content)
		{
			foreach ($content AS $sKey => $sContent) 
			{
				// Is het een hoofdblock of een nested block?
				if($sKey == 'ROOT_'.$sIn) {
					$sIn = 'ROOT_'.$sIn;
					$sFile = $key;
				}
				elseif($sKey == $sIn) $sFile = $key;

				// Is het een hoofdblock of een nested block?
				if($sKey == 'ROOT_'.$sOut) $sOut = 'ROOT_'.$sOut;

				if($sKey == $sOut) 
				{ 
					if(isset ($sEnd) && $sEnd != NULL) {
						if(isset($this->sBlocks [$sFile][$sIn]) && isset($this->sBlocks [$key][$sOut])) 
							$this->sBlocks [$sFile][$sIn] = str_replace ("{".$sEnd."}", $this->sBlocks [$key][$sOut], $this->sBlocks [$sFile][$sIn]);
						else $this->errors [] = $sOut.' kon niet in het block '.$sIn.' worden gezet.';	

						if(isset ($sPagina) && !empty ($sPagina)) $this->Parse_Out ($sFile, $sIn, 'winkels');
						else $this->Parse_Out ($sFile, $sIn);
					}
					else {
						$this->sBlocks [$sFile][$sIn] = str_replace ('{'.$sOut.'}', $this->sBlocks [$key][$sOut].'{'.$sOut.'}', $this->sBlocks [$sFile][$sIn]);
						@$this->sBlocks [$key][$sOut] = $this->sBuffer [$key][$sOut];
					}
				}
			}
		}
	}

	function Parse_Out ($sFile, $sBlock, $sPagina = NULL) {
		## Globals replacen
		$this->check_vars ($sFile, $sBlock, array ('global', 'get', 'lang', 'cookie'));

		## Gaat het om script.php?
		if($this->sScript == 0) {
			$sOutput = preg_replace ("/{(.*?)}/is", "", $this->sBlocks [$sFile][$sBlock]);
			$sOutput = preg_replace ("/<string (.*?)>/is", "", $sOutput); 
		}
		else { 
			if($sPagina == 'winkels') {
				$sOutput = preg_replace ("/<string (.*?)>/is", "", $this->sBlocks [$sFile][$sBlock]); 
				if(preg_match_all("/{(.*?)}/ism", $sOutput, $sMatches)) {
					for ($i = 0; $i < count ($sMatches[0]); $i++) 
					{
						/*
						Bij Script.php, wordt het script tussen {} geplaatst, aangezien hier alles tussen {} weggehaald wordt moest ik even een extra code plaatsen speciaal voor script.php
						Alleen alles tussen {} dat kleiner is dan 25 tekens wordt vervangen door niets.
						*/

						if(strlen ($sMatches[0][$i]) < 10) 
							$sOutput = str_replace ($sMatches[0][$i], '', $sOutput);

					}
				} 
				$sOutput = str_replace ('{sToevoegen}', '', $sOutput);
				$sOutput = str_replace ('{Geboden_Geen}', '', $sOutput);
				$sOutput = str_replace ('{Berichten_R}', '', $sOutput);
				$sOutput = str_replace ('{Berichten_Geen}', '', $sOutput);
				$sOutput = str_replace ('{Geboden_R}', '', $sOutput);
				$sOutput = str_replace ('{Thumbs_R}', '', $sOutput);
				$sOutput = str_replace ('{zThumbs_R}', '', $sOutput);
				$sOutput = str_replace ('{Thumbs_Geen}', '', $sOutput);
				$sOutput = str_replace ('{Relevant_R}', '', $sOutput);
				$sOutput = str_replace ('{mSubcategorieen_R}', '', $sOutput);
				$sOutput = str_replace ('{mLinkpartners_R}', '', $sOutput);
				$sOutput = str_replace ('{mLinkpartners_Geen}', '', $sOutput);
				$sOutput = str_replace ('{mCategorieen_R}', '', $sOutput);
				$sOutput = str_replace ('{mCategorieen_Geen}', '', $sOutput);
				$sOutput = str_replace ('{iPagina_R}', '', $sOutput);
				$sOutput = str_replace ('{Redirect}', '', $sOutput);
				$sOutput = str_replace ('{nIngelogd}', '', $sOutput);
				$sOutput = str_replace ('{Laatste_R}', '', $sOutput);
				$sOutput = str_replace ('{mPaginas_R}', '', $sOutput);
				$sOutput = str_replace ('{zReageren}', '', $sOutput);
				$sOutput = str_replace ('{nReageren}', '', $sOutput);
				$sOutput = str_replace ('{Gmaps_Geen}', '', $sOutput);
			}
			else {
				$sOutput = preg_replace ("/<string (.*?)>/is", "", $this->sBlocks [$sFile][$sBlock]); 
				if(preg_match_all("/{(.*?)}/ism", $sOutput, $sMatches)) {
					for ($i = 0; $i < count ($sMatches[0]); $i++) 
					{
						/*
						Bij Script.php, wordt het script tussen {} geplaatst, aangezien hier alles tussen {} weggehaald wordt moest ik even een extra code plaatsen speciaal voor script.php
						Alleen alles tussen {} dat kleiner is dan 25 tekens wordt vervangen door niets.
						*/

						if(strlen ($sMatches[0][$i]) < 25) 
							$sOutput = str_replace ($sMatches[0][$i], '', $sOutput);

					}
				} 
			}
		}
		$sOutput = str_replace ("{sGoogleMap_R}", "", $sOutput);
		echo $sOutput;
	}

	function _error () {
		if(is_array ($this->errors)) foreach ($this->errors AS $content) echo $content.'<br />';
		else echo $this->errors [0];
	}
}
?>

Alvast heel erg bedankt voor de hulp!

Mvg,
Tim van Zon
 
Laatst bewerkt door een moderator:
Hoi Tim

Je fout zit hem in je Registry.php

Oplossing 1
PHP:
static private $vars = array();

Gezien dit een static variabele is kan je die niet uit een object class aanroepen. Je kan dit aanpassen met de volgende text.

PHP:
private $vars = array();

Zoals je ziet heb ik het woordje static weggehaald om de variabele in een object variabele te maken. Nu kun je wel deze variabele aanroepen.

Oplossing 2
Wanneer je een static variabele wil aanvragen vanuit een object gebruik je niet.
PHP:
$this->vars
maar
PHP:
self::$vars

Omdat de variabele een private variabele is zal alleen functies uit dezelfde class deze variabele aan kunnen roepen en is dus oplossing 1 eigenlijk de beste.

Hier wat mooi leesvoer over php classes en objecten. (Wel engels)
 
Laatst bewerkt door een moderator:
Verplaatst van MySQL naar PHP.

@Paul 119: In plaats van het in je bericht te vermelden had je ook een misbruikmelding kunnen doen zodat een moderator het kan regelen.
 
Hee Paul!

Heel erg bedankt.
Er blijven nu nog maar 2 foutmeldingen staan nadat ik private $vars = array(); heb geplaatst.
Echter wanneer ik $this->vars in self::$vars probeerde te veranderen gaf hij niks meer weer op de website.

Gr,
Tim van Zon
 
Wat bedoel je?

Dat je probleem met self::$vars is opgelost of dat hij het compleet niet meer doet?
 
Nee,

Ik heb de oplossing van private $vars = array(); toegepast en dit werkte. Er waren vervolgens nog maar 2 foutmeldingen.

Strict Standards: Only variables should be passed by reference in /home/timievz/domains/girlmarkt.nl/public_html/classes/template.php on line 20

Strict Standards: Only variables should be passed by reference in /home/timievz/domains/girlmarkt.nl/public_html/classes/template.php on line 20



Wanneer ik oplossing self::$vars daarvoor probeerde toe te passen kwam de hele site niet meer in beeld..
Enig idee?

Nog bedankt voor je snelle reactie, TOP!
 
Laatst bewerkt:
Dit zijn 2 opzichzelf staande foutmeldingen die met een array te maken hebben. Wat er precies misgaat durf ik zo niet te zeggen het zit in je define functie op template.php. Als je wild zou ik hier even een copie van je site moeten draaien om wat te debuggen. Wat precies in de dunctie gebeurd. Kan je een copie van je site toesturen met database zodat ik even wat kan testen webmaster@paules.eu. Wanneer ik meer weet laat ik het weten.
 
Ik heb je site bekeken en vond het probleem in je template.php file. de php functie end() mag alleen een variable hebben.
PHP:
$sNaam = end (explode ('/', $sPad));
(lijn 20)

vervangen voor deze code.
PHP:
$endPad = explode ('/', $sPad);
$sNaam = end($endPad);

Dat loste de laatste foutmelding op.
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan