php variable scope issue

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
definewebsites
Forum Newbie
Posts: 19
Joined: Thu May 01, 2008 9:51 pm

php variable scope issue

Post by definewebsites »

Hi there,

I am implementing a hit counter on a website using cookies and have some php script that retrieves the count from adatabase and assigns it to a variable. I have this script at the top of the page before all the html related syntax.

I am printing the count in the footer of my pages, which is obtained externally through a php 'include' statement.

However, the count does not show. Nothing appears on the screen. I would like to know whether the variable created at the top of the page has page-wide significance. I created the variable with the 'global' syntax, and it should work. However it is not.

Any ideas?

Cheers
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Re: php variable scope issue

Post by kendall »

I don't think the cookie would be recognized until the page is refreshed...
Post Reply