Home | Registrieren | Einloggen | Suchen | Aktuelles


Forum » PHP & MySQL » PHP 5 - Funktionsaufruf Antworten
PHP 5 - Funktionsaufruf

aykut
Otto-Normal-Poster


Beiträge: 82


Ich haben vor 2 Tagen mit PHP 5 angefangen. Da habe ich eine Frage.

In dem folgenden Code habe ich eine Klasse mit 3 Funktionen.
Die 3. Funktion displayTemplate() ruft die 1. Funktion getCallerFilePath() auf.

Dateiname: smarty_connect.php
1: 
2: 
3: 
4: 
5: 
6: 
7: 
8: 
9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
19: 
20: 
21: 
22: 
23: 
24: 
25: 
26: 
27: 
28: 
29: 
30: 
31: 
32: 
33: 
34: 
35: 
36: 
37: 
38: 
39: 
40:
<?php
require('libs/Smarty.class.php');

class smarty_connect extends Smarty
{
	function getCallerFilePath() {
		error_reporting(E_ALL);
		$stack = debug_backtrace();
	    $caller = $stack[0];	
		$path = explode('/', $caller['file']);
		echo $path[0];
	}
	
   function smarty_connect()
   {
   		$fixpath = dirname(__FILE__);
   		$fixpath = str_replace("\\","/",$fixpath);

		$this->Smarty();

		$this->template_dir = $fixpath."/templates";
		$this->config_dir = $fixpath."/configs";
		$this->compile_dir = $fixpath."/compiles";
		$this->cache_dir = $fixpath."/cache";

		$this->clear_compiled_tpl();
   }


	function displayTemplate($template) {
		error_reporting(E_ALL);

		getCallerFilePath();
 		
		//do something
	}

}
?>


Ich bekomme die Fehlermeldung:
1: 
2:
Fatal error: Call to undefined function getCallerFilePath() in 
C:\Programme\Apache Group\Apache2\htdocs\friseur\smarty\smarty_connect.php on line 33


Wieso bekomme ich diese Meldung, die Funktion existiert aber!?!?!

Wenn ich die getCallerFilePath() Funktion, d.h. die aufgerufene angeblich nicht
existierende Funktion aus der Klasse rausnehme, aber in der selben Daten und direkt
über die Klasse schreibe, wie folgt, dann geht es. Aber wieso gehts nicht wie oben?

1: 
2: 
3: 
4: 
5: 
6: 
7: 
8: 
9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
19: 
20: 
21: 
22: 
23: 
24: 
25: 
26: 
27: 
28: 
29: 
30: 
31: 
32: 
33: 
34: 
35: 
36: 
37: 
38: 
39: 
40: 
41: 
42:
<?php
require('libs/Smarty.class.php');

	function getCallerFilePath() {
		error_reporting(E_ALL);
		$stack = debug_backtrace();
	    $caller = $stack[0];	
		$path = explode('/', $caller['file']);
		echo $path[0];
	}
	
	
class smarty_connect extends Smarty
{

   function smarty_connect()
   {
   		$fixpath = dirname(__FILE__);
   		$fixpath = str_replace("\\","/",$fixpath);

		$this->Smarty();

		$this->template_dir = $fixpath."/templates";
		$this->config_dir = $fixpath."/configs";
		$this->compile_dir = $fixpath."/compiles";
		$this->cache_dir = $fixpath."/cache";

		$this->clear_compiled_tpl();
   }


	function displayTemplate($template) {
		error_reporting(E_ALL);

		getCallerFilePath();
 		
		//do something
	}

}
?>


danke
Aykut

Diese Nachricht wurde geändert von: aykut
  Profil   Editieren   Zitieren

languitar
Foren-Team


Beiträge: 2795


$this->get CalleFilePath()

---
Take a look here!
Lichtblick - Einblick - Ausblick

  Profil   E-Mail   Website   Editieren   Zitieren

aykut
Otto-Normal-Poster


Beiträge: 82


OOP ist doch nicht OOP ... ich dachte es wäre wie java.

danke Dir für die Hilfe
-Aykut

  Profil   Editieren   Zitieren
 

Antworten
Nach oben