Passing Variables and the include command

From: Date: Wed, 19 Sep 2001 05:34:12 +0000
Subject: Passing Variables and the include command
Groups: php.general 
Request: Send a blank email to php-general+get-67790@lists.php.net to get a copy of this message
I was wondering if it is possible to pass some variables to a php file that will be accessed via the include command? For example, I am working on creating a nicer "hits" counter and would like to just write the code for the counter once and then have each page access that counter.php3 and pass a variable which would contain the page name to counter.php3 so counter.php3 could write the new counter to a file with the pageName.log. Right now I am using a very simple counter: -counter.php3- $file = "interest"; $counterFile=fopen("$file".".log","r"); $counterRecord = trim( fgets($counterFile, 4096) ); fclose($counterFile); $counterRecord++; $counterFile = fopen("$file".".log", "w"); fwrite($counterFile,"$counterRecord"); fclose($counterFile); Ideally, I would like to have each of my pages call counter.php3 using the include command and have the page pass it the variable $file. Any ideas? Thanks, Andrew V. Romero

« previous php.general (#67790) next »