Page 1 of 1

Assign an include eg $include

Posted: Wed Jan 15, 2003 5:11 pm
by Darkside
Ok I'm having real problems making this view how many members are online codes. NOT USING MYSQL! I'm getting really far but I'm having a problem in has I need to compare two numbers 1 of witch is in a text file (other is the time). Witch I need to load and define so I can call it against the other number. The only way I seem to be able to get the text file to show my numbers and not the array number is bye doing?

Code: Select all

Include (1.txt);
but I need to be able to define this to say $num1 so this I can then run this

Code: Select all

if ($timestamp < $num1) &#123;
Include ("add.php");
&#125;else&#123;
Include ("take.php");
&#125;
The add and take folders are just a counter 1 adds and 1 takes away.. I'm sure you get the idea? So any way you cant define this include ? any idea would help other then use Mysql

Posted: Wed Jan 15, 2003 5:51 pm
by Morbius
to the best of my knowledge you can not turn a include "" into a variable.

Have you tried if/else statements? for example: a match statement to check what the user has done, and if the user has done one thing it includes thus, and visa-versa?

Posted: Wed Jan 15, 2003 10:37 pm
by volka
sorry, I didn't understand the question completely but maybe this example covers it ...maybe not ;)

Code: Select all

// one.php
<?php
function myFunc($param)
{
	return $param+1;
}
echo 'one.php has been included<br />';
return 'one.php';
?>

Code: Select all

// two.php
<?php
function myFunc($param)
{
	return $param-1;
}
echo 'two.php has been included<br />';
return 'two.php';
?>

Code: Select all

<?php
	$possible = array('one.php', 'two.php');
	shuffle($possible);
	
	$which = require($possible[0]);
	echo $which, '<br />', myFunc(10);
?>
now call test.php several times.
http://www.php.net/manual/en/function.include.php

I didnt need that..

Posted: Thu Jan 16, 2003 4:41 am
by Darkside
I dont know howto explain it any more then I have but basicly wot i've made is a code that can be added to anypage.

When the code runs it does this..

1 //Adds 1 to hits.txt
2 //Print the current time in a txt file named the number currently in hits
3 //Make a php file also named the current hits.

*this bit need to be done next
4 //add page to the array
5 //Check all run all php files in the array

and wot i need the php files to do eg lets take the number 1

this is wots ment to happen
6 //Get the time printed in 1.txt
7 // then check to see the cuerrnt time is over 300 second
8 //if its under it means add 1 to how many users are online
9 // else remove 1 from users online.

all i need is to do is be able to call the numer printed in the text file to the curent time.