Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

one question of {include php file}

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
joey
Smarty Regular


Joined: 29 Oct 2003
Posts: 57

PostPosted: Wed Oct 29, 2003 9:49 am    Post subject: one question of {include php file} Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Wed Oct 29, 2003 10:11 am    Post subject: Reply with quote

if your $lang is a template-variable:

{include php file="main.php" lang=$lang}
Back to top
View user's profile Send private message Send e-mail Visit poster's website
joey
Smarty Regular


Joined: 29 Oct 2003
Posts: 57

PostPosted: Wed Oct 29, 2003 10:24 am    Post subject: how to access this variable? Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Wed Oct 29, 2003 10:34 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP