|
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 |
joey Smarty Regular
Joined: 29 Oct 2003 Posts: 57
|
Posted: Wed Oct 29, 2003 9:49 am Post subject: one question of {include php file} |
|
|
I try to use this function to build a multple page processor
{include php file="main.php?lang=$lang"}
if there are no variables, it can run. if I add this "?lang=$lang" , error appear. "...file:main.php?user=user is not readable in ...." (err msg).
I just want to know ,how to transfer the params in include php file? |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Wed Oct 29, 2003 10:11 am Post subject: |
|
|
if your $lang is a template-variable:
{include php file="main.php" lang=$lang} |
|
Back to top |
|
joey Smarty Regular
Joined: 29 Oct 2003 Posts: 57
|
Posted: Wed Oct 29, 2003 10:24 am Post subject: how to access this variable? |
|
|
1. in the main.php
I just try to use : echo $_GET['lang']; it can't access the $lang;
pls tell me how to do ?
2. and I try to access the session in a included php , can't access.I don't know why? |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Wed Oct 29, 2003 10:34 am Post subject: |
|
|
your included php is called inside a function (better: inside a method of your $smarty-object).
that means:
- if you want to access global php-variables, you have to declare them global or use $GLOBALS['varname']. the special $_GET, $_POST etc. are auto-global, they are accessible without the need to declare them as global.
- if you want to access smarty's template-variables you can use
$this->get_template_vars('varname') |
|
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
|