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

problem with globals (?)

P: n/a
Hi there,

I have a center-file index.php
in it various files are included: inc/config.php, inc/functions.php

in config.php $pagetitle is declared.
if i call Header(), located in functions.php, it builds the header
part:
<html> thrue to <body> (by including header.php)
the pagetitle is reffered to as $GLOBALS['pagetitle'] and that works.

i also have a function in functions.php called NotPriviledged( $title,
$meta, $java )
It returns
Header();
echo 'You are not priviledged to view this page.';
Footer();

$title is meant for an additional pagetitle, $meta for additional
meta-tags, and java for additional javascripts.

Somehow, i'm unable to get the variables inside Header() (/header.php)
by calling NotPriviledged.

How do i get them in there?

Frizzle.

Jun 27 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
before you call function NotPriviledged,
have you assign a value to $GLOBALS['pagetitle'] ?

this global variable might be empty because you only declare $pagetitle
not the global variable. The $pagetitle value is not accessible from
NotPriveledged function.

--
http://blog.deshot.com
http://www.groupvita.com
frizzle wrote:
Hi there,

I have a center-file index.php
in it various files are included: inc/config.php, inc/functions.php

in config.php $pagetitle is declared.
if i call Header(), located in functions.php, it builds the header
part:
<html> thrue to <body> (by including header.php)
the pagetitle is reffered to as $GLOBALS['pagetitle'] and that works.

i also have a function in functions.php called NotPriviledged( $title,
$meta, $java )
It returns
Header();
echo 'You are not priviledged to view this page.';
Footer();

$title is meant for an additional pagetitle, $meta for additional
meta-tags, and java for additional javascripts.

Somehow, i'm unable to get the variables inside Header() (/header.php)
by calling NotPriviledged.

How do i get them in there?

Frizzle.


Jun 27 '06 #2

P: n/a
*** frizzle escribió/wrote (27 Jun 2006 03:05:52 -0700):
Somehow, i'm unable to get the variables inside Header() (/header.php)
by calling NotPriviledged.

How do i get them in there?


Check this:

http://es2.php.net/global

<?php
$a = 1;
$b = 2;

function Sum()
{
global $a, $b;

$b = $a + $b;
}

Sum();
echo $b;
?>

--
-+ Álvaro G. Vicario - Burgos, Spain
++ http://bits.demogracia.com es mi sitio para programadores web
+- http://www.demogracia.com es mi web de humor libre de cloro
--
Jun 27 '06 #3

P: n/a
http://us3.php.net/manual/en/function.header.php

header() is a built in function used to send HTTP headers. Change the
name.

You should be seeing an error unless you've turned them off.

frizzle wrote:
Hi there,

I have a center-file index.php
in it various files are included: inc/config.php, inc/functions.php

in config.php $pagetitle is declared.
if i call Header(), located in functions.php, it builds the header
part:
<html> thrue to <body> (by including header.php)
the pagetitle is reffered to as $GLOBALS['pagetitle'] and that works.

i also have a function in functions.php called NotPriviledged( $title,
$meta, $java )
It returns
Header();
echo 'You are not priviledged to view this page.';
Footer();

$title is meant for an additional pagetitle, $meta for additional
meta-tags, and java for additional javascripts.

Somehow, i'm unable to get the variables inside Header() (/header.php)
by calling NotPriviledged.

How do i get them in there?

Frizzle.


Jun 28 '06 #4

P: n/a

ImOk wrote:
http://us3.php.net/manual/en/function.header.php

header() is a built in function used to send HTTP headers. Change the
name.

You should be seeing an error unless you've turned them off.

frizzle wrote:
Hi there,

I have a center-file index.php
in it various files are included: inc/config.php, inc/functions.php

in config.php $pagetitle is declared.
if i call Header(), located in functions.php, it builds the header
part:
<html> thrue to <body> (by including header.php)
the pagetitle is reffered to as $GLOBALS['pagetitle'] and that works.

i also have a function in functions.php called NotPriviledged( $title,
$meta, $java )
It returns
Header();
echo 'You are not priviledged to view this page.';
Footer();

$title is meant for an additional pagetitle, $meta for additional
meta-tags, and java for additional javascripts.

Somehow, i'm unable to get the variables inside Header() (/header.php)
by calling NotPriviledged.

How do i get them in there?

Frizzle.


Header() was a mistake of mine, i called it Head(); ( and Foot(); )
Anyway, i'll have time to look at your responses in the evening.
Thanks!

Jun 28 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.