Can i set session variables based on the variable input into the function. Such as:
function check($value){
$_SESSION['$value'];
//session checks
}
Can i set session variables based on the variable input into the function. Such as:
function check($value){
$_SESSION['$value'];
//session checks
}
Yes, but it would have to be $_SESSION[$value]
. Single quoted strings are literal and do not have variable substitution (not that quotes are even needed in this case).
usually you would use a key and a value, depends what you're trying to do i guess and what $value
is
function check($value){
$_SESSION[$value] = $value;
//session checks
}
It is possible yes, but i would warn you to what the porpouse you want it for it might turn out to be an unusable thing.
<?php
session_start();
echo 'Welcome to the test';
$_SESSION['time'] = time();
echo '<br /><a href="test.php">Refresh Me (' . check('time') . ') </a>';
function check($value){
return $_SESSION[$value];
}
?>