WebWork Magazin - Webseiten erstellen lassen, Online Medien, html

Webhoster, Webhosting Provider und Domain registrieren

Home | Registrieren | Einloggen | Suchen | Aktuelles | GSL-Webservice | Suleitec Webhosting
Reparatur-Forum | Elektro forum | Ersatzteilshop Haushalt und Elektronik


Homepage und Webhosting-Forum

Scripte und Programme für PHP, MYSQL. Diskussionen zur Programmierung im Web. Fragen zu CMS, Blogsoftware, Shops, Newsletter und vielen weiteren Scripten.


Forum » PHP & MySQL » PHP 5 - Funktionsaufruf » Antworten
Benutzername:
Passwort: Passwort vergessen?
Inhalt der Nachricht: Fett | Kursiv | Unterstrichen | Link | Bild | Smiley | Zitat | Zentriert | Quellcode| Kleiner Text
Optionen: Emailbenachrichtigung bei Antworten
 

Die letzten 5 Postings in diesem Thema » Alle anzeigen
von aykut
OOP ist doch nicht OOP ... ich dachte es wäre wie java.

danke Dir für die Hilfe
-Aykut
von languitar
$this->get CalleFilePath()
von aykut
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

Nach oben