|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
hucky Smarty Rookie
Joined: 02 Sep 2004 Posts: 6
|
Posted: Thu Sep 02, 2004 3:41 pm Post subject: PHP Variablen/Arrays haben keinen Wert nach {include_php} |
|
|
Hi zusammen
ich versuche mit {include_php} eine php datei zu includen in der ist ein array (z bsp $config[file][extenstion]) definiert aber nach dem includen ist das array leer und keine der variablen hat einen wert
warum? was mache ich falsch?
gruss hucky |
|
Back to top |
|
kills Smarty Elite
Joined: 28 May 2004 Posts: 493
|
Posted: Fri Sep 03, 2004 7:41 am Post subject: |
|
|
dein code?
innerhalb des includes sollten alle variablen vorhanden sein, die auch im Script vorhanden waren, das durch den Browser aufgerufen worden ist. |
|
Back to top |
|
hucky Smarty Rookie
Joined: 02 Sep 2004 Posts: 6
|
Posted: Fri Sep 03, 2004 7:50 am Post subject: also |
|
|
mein code...
im smarty template mache ich {include_php file=gallery/index.php}
der php code sieht so aus (index.php:
[php:1:5d90c2a083]<?
require('start.inc.php');
if (isset($_GET['path'])) {
$tmppath = base64_decode($_GET['path']);
}
else {
$tmppath = '/';
}
if (isset($_GET['page'])) {
$page = $_GET['page'];
}
else {
$page = 1;
}
$cols = $config['design']['cols'];
$rows = $config['design']['rows'];
$perpage = $cols * $rows;
$path = url_path($tmppath);
...
?>
start inc
<?
$db_conn = false;
session_start();
require('config.inc.php');
$config['dir']['self'] = dirname(realpath(__FILE__));
require('language/' . $config['design']['language'] . '.inc.php');
require('functions.inc.php');
if (isset($_GET['login'])) {
login();
}
else if (isset($_GET['logout'])) {
$_SESSION['user'] = NULL;
}
$version = "0.1.3c";
$is_admin = ($_SESSION['user']['user'] == 'admin');
?>
config inc
<?
$config['dir']['pics'] = 'pics';
$config['dir']['temp'] = 'tmp';
// mysql connection settings
$config['mysql']['host'] = 'localhost';
$config['mysql']['user'] = 'deruser';
$config['mysql']['pass'] = 'daspasswort';
$config['mysql']['database'] = 'die datenbank';
$config['mysql']['tableprefix'] = 'pwa_';
...
?>[/php:1:5d90c2a083]
und jetzt ist das ganze config array leer..
warum?
gruss & danke |
|
Back to top |
|
kills Smarty Elite
Joined: 28 May 2004 Posts: 493
|
Posted: Fri Sep 03, 2004 7:58 am Post subject: |
|
|
versuch ma hier ohne das require:
[php:1:06afbeacf3]
<?
// require('start.inc.php'); hier das ma raus
if (isset($_GET['path'])) {
$tmppath = base64_decode($_GET['path']);
}
else {
$tmppath = '/';
}
if (isset($_GET['page'])) {
$page = $_GET['page'];
}
else {
$page = 1;
}
$cols = $config['design']['cols'];
$rows = $config['design']['rows'];
$perpage = $cols * $rows;
$path = url_path($tmppath);
...
?>
[/php:1:06afbeacf3] |
|
Back to top |
|
hucky Smarty Rookie
Joined: 02 Sep 2004 Posts: 6
|
Posted: Fri Sep 03, 2004 12:52 pm Post subject: ne... |
|
|
geht nicht...
ich habe mehr herausgefunden die variablen sind ausserhalb der funktion da....
innerhalb der funktion nicht...
aber ich habe ein global $config gemacht innerhalb der funktion
muss ich das array noch speziell registrieren?
oder sonst noch was machen??
gruss |
|
Back to top |
|
kills Smarty Elite
Joined: 28 May 2004 Posts: 493
|
Posted: Mon Sep 06, 2004 6:45 am Post subject: Re: ne... |
|
|
hucky wrote: | geht nicht...
ich habe mehr herausgefunden die variablen sind ausserhalb der funktion da....
innerhalb der funktion nicht...
aber ich habe ein global $config gemacht innerhalb der funktion
muss ich das array noch speziell registrieren?
oder sonst noch was machen??
gruss |
nein global alleine reicht aus! |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|