using a variable from a separate file without using import

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Smudly
Forum Commoner
Posts: 71
Joined: Wed Jun 09, 2010 10:09 pm

using a variable from a separate file without using import

Post by Smudly »

I have created a file called onlineusers.php that figures out how many users there currently are online. At the end of the script is a variable that captures the final number. I want to be able to use ONLY this variable in a separate file called members.php

How do I go about doing something like this?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: using a variable from a separate file without using impo

Post by requinix »

Move the code that calculates the number into a function in a separate file. Then have both scripts include the file and call the function.
Post Reply