vrmetro
asked on
Trying to setup a function
Can you tell me what I'm doing wrong here?
//Set Function
function check_field($field) {
if (isset($_SESSION[''.$field.''])) {
$field = $_SESSION[''.$field.''];
} else {
$field='';
}
//Call function
check_field(M_buss_name);
Still had some syntax issues, should read:
<?php
$field='';
$_SESSION['M_buss_name']="some value";
function check_field($fld) {
global $field;
$field = isset($_SESSION[$fld]) ? $_SESSION[$fld] : '' ;
}
check_field('M_buss_name');
echo $field;
?>
ASKER
I wanted a function that would do what I'm doing below, later in the page I print the variable either blank or with whatever is in it.
Per the code below, it doesn't simplify me writing below over and over again because I'll need to define:
$_SESSION['M_buss_name']=" some value";
Will I need that there?
Per the code below, it doesn't simplify me writing below over and over again because I'll need to define:
$_SESSION['M_buss_name']="
Will I need that there?
if ( isset($_SESSION['MC_vatnr'])) {
$MC_vatnr=$_SESSION['MC_vatnr'];
} else {
$MC_vatnr='';
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Beautiful, thank you!
Open in new window