Connecting Tech Pros Worldwide Help | Site Map

variables (new to php! please help me!)

SA
Guest
 
Posts: n/a
#1: Jul 17 '05
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
Kevin Thorpe
Guest
 
Posts: n/a
#2: Jul 17 '05

re: variables (new to php! please help me!)


SA wrote:[color=blue]
> 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.[/color]

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

Rahul Anand
Guest
 
Posts: n/a
#3: Jul 17 '05

re: variables (new to php! please help me!)


diodorus@hotmail.com (SA) wrote in message news:<48613b32.0312020251.2433ebb2@posting.google. com>...[color=blue]
> 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[/color]

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
Closed Thread