By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 943 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

variables (new to php! please help me!)

P: n/a
SA
hello,

i have many pages (page1.php .. page100.php) and each of them include
some fixed subpages (top.php, bottom.php).
each subpage (top.php, bottom.php) uses a variable ("theme") defined
in its "parent" (one of the pageX.php).
this variable is also used (not only defined) in the parent page
itself. i would like to have the variable "theme" defined in a single
external file, instead of defyning it for every page. is it possible?

sorry for the probably stupid question, im new to php.

thank you in advance.
lx
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
SA wrote:
hello,

i have many pages (page1.php .. page100.php) and each of them include
some fixed subpages (top.php, bottom.php).
each subpage (top.php, bottom.php) uses a variable ("theme") defined
in its "parent" (one of the pageX.php).
this variable is also used (not only defined) in the parent page
itself. i would like to have the variable "theme" defined in a single
external file, instead of defyning it for every page. is it possible?

sorry for the probably stupid question, im new to php.


If you include your fixed content early enough then simply define $theme
in top.php.

Jul 17 '05 #2

P: n/a
di******@hotmail.com (SA) wrote in message news:<48**************************@posting.google. com>...
hello,

i have many pages (page1.php .. page100.php) and each of them include
some fixed subpages (top.php, bottom.php).
each subpage (top.php, bottom.php) uses a variable ("theme") defined
in its "parent" (one of the pageX.php).
this variable is also used (not only defined) in the parent page
itself. i would like to have the variable "theme" defined in a single
external file, instead of defyning it for every page. is it possible?

sorry for the probably stupid question, im new to php.

thank you in advance.
lx


Hi,

Yes, you can include a fixed external file which declares and defines
all global variables to be used. For example you can create a file
(config.php)
define some variables here ($globTheme = 'classic').
In all other files just include this file as first statement.
Afterwards it will be available to the main file and all other
included files. But remember that whenever you change the value of a
variable, old value will get lost (depends on the scope of variable).

regards,
rahul
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.