Code: Select all
$phone_num = '';
function empty_var($var) {
if(empty($var)) {
$var = 'This variable is empty<br>';
}
}
empty_var($phone_num);
echo $phone_num;Moderator: General Moderators
Code: Select all
$phone_num = '';
function empty_var($var) {
if(empty($var)) {
$var = 'This variable is empty<br>';
}
}
empty_var($phone_num);
echo $phone_num;php_wiz_kid wrote:What's wrong with my function:
It doesn't echo anything. I'm new to functions so this is probably really bad, but bear with me please.Code: Select all
$phone_num = ''; // -V- look here, add the ampersand (&) function empty_var(&$var) { if(empty($var)) { $var = 'This variable is empty<br>'; } } empty_var($phone_num); echo $phone_num;