Welcome to WebmasterWorld Guest from 54.145.208.64

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Variables

Few questions

   
10:31 pm on Aug 11, 2004 (gmt 0)

10+ Year Member



How do you call a variable from a page?

I have index.php contain variables, then this loads up a template page that calls the variables... now how do you have a page like header.php then have a variable from that page get called?

Also every page is different in that some pages have 5 tables, some have 3. how could I code this to work out? I have a template and need it to call a variable that can contain the code, but how would it know to add another line?

2:39 pm on Aug 12, 2004 (gmt 0)

WebmasterWorld Administrator ergophobe is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



It's all about scope [us3.php.net], not just a mouthwash any more.

Basically, any variable that is defined in the main file or a file that was folded into the main file with include() or require() will be available downstream (i.e. after the point it was included).

Within functions, the scope is local, meaning the variable is only available within the function. Typically, to get a single value out of a function, you use the 'return' statement to return a value.

If you can read through the manual and maybe find some other pages (search on "variables scope php") to help you get the basics down, a lot of other threads on templates will become much, much clearer to you.

Tom

10:08 pm on Aug 12, 2004 (gmt 0)

10+ Year Member



Bah I hate those damn things. if a=1 and b=0, grrrrr i searched it but it didn't seem to have anything I needed.

If what you say is true then if I have a page get called up then i can call it up, how i dunno b/c that article is freaking confusing.

11:56 pm on Aug 12, 2004 (gmt 0)

10+ Year Member



I tested "scope" and that worked quite nicely. I called it up in my index page, the index page then asked for that variable and that it called it up automatically ^.^