17488 Posts in 4473 Topics by 1978 members
| Go to End | Next > | |
| Author | Topic: | 4798 Views |
-
where define my global variable?I have Error

2 December 2008 at 5:00am
Hi!
I need define a global variable in my Page.php. I put global $a =0 after Page controller but is wrong..can you hel me to define my global varable?Where?Thanks -
Re: where define my global variable?I have Error

2 December 2008 at 10:14am
Use your _config.php file.
-
Re: where define my global variable?I have Error

3 December 2008 at 9:01pm
I use mysite/_config.php and I set:
global $a;
$a = 0;
then in my function I recall $a in this way:
global $a;
but seems not be a global variable.. -
Re: where define my global variable?I have Error

3 December 2008 at 9:10pm
the problem is how recall ths global variable in my template
-
Re: where define my global variable?I have Error

4 December 2008 at 5:12pm
If you want it in the template then you have to wrap it in a PHP function which returns the global.
So try this in your Page.php file
function SomeVar() {
global $_SOME_VAR;
return $_SOME_VAR;
} -
Re: where define my global variable?I have Error

4 December 2008 at 9:42pm
so in my config.php I can't declare nothing?
sorry but in my program I have may problem and i'm not sure the cause is global variable.. -
Re: where define my global variable?I have Error

4 December 2008 at 11:10pm
ok..I understand what you say but my problem is that if my function return global variable (global value are 1 or 0) and call the function in template I see only 1 or 0 and all template disappear.
I need to use global value in template to print two different menu:
if global variable is equals to 1 print all menu otherwise if global variable is equals to 0 only 2 voices of menu.so I recall function as:
<% if Somevar = 1 %>
....
<% else %>
..
<% end_if %> -
Re: where define my global variable?I have Error

5 December 2008 at 12:10am
Just out of interest, howcome you need to use a global variable?
| 4798 Views | ||
| Go to Top | Next > |




