Is there a way to set a value for a variable according to the number of times the file has been loaded ?
Example:
for first time loaded $value = hello.
for second time loaded $value = bye.
echo "$value";
Is there a way to set a value according to the number of tim
Moderator: General Moderators
Re: Is there a way to set a value according to the number of tim
Yes there is. You will need to track a persistent variable such as a $_SESSION, $_COOKIE, $_POST or $_GET.
Re: Is there a way to set a value according to the number of tim
Try this code,
Code: Select all
<?php
session_start();
// Use $HTTP_SESSION_VARS with PHP 4.0.6 or less
if (!isset($_SESSION['count'])) {
$_SESSION['count'] = 0;
} else {
$_SESSION['count']++;
}
print $_SESSION['count'];
?>