How could i get all declared variables in PHP ?
The get_defined_vars() function is an inbuilt function in PHP which is used to returns an array of all defined variables. This function returns a multidimensional array which contains all the list of variables, environment etc. Parameters: This function does not accepts any parameter.
The var_dump() function dumps information about one or more variables. The information holds type and value of the variable(s).
EXxample:
<?php
var_dump(get_defined_vars());
?>
We can use this function can see all variables declared in your code at once.!
ex:
<?php
Input :
$esi_percentage_value = get_app_config('e_s_i');
$e_d_o_value = get_app_config('esi_deduction_on');
$s = (($salary['check_amt'] / $emp_tot_month_days) * $tot_pre_days);
$esi_amt = (($s * $esi_percentage_value) / 100);
$esideduct = round($esi_amt);
$esidedon = round($emp_total_present_days_salary);
$s = (($salary['check_amt'] / $emp_tot_month_days) * $tot_pre_days);
$esi_amt = (($s * $esi_percentage_value) / 100);
$esideduct = round($esi_amt);
$esidedon = round($emp_total_present_days_salary);
$percentage_value = get_app_config('p_f');
$emppf = $pf_deducted_on * $percentage_value;
$pt_first_basic_amount_value = get_app_config('pt_first_basic_amount');
$pt_first_basic_limit_value = get_app_config('pt_first_basic_limit');
$pt_final_amount_value = get_app_config('pt_final_amount');
echo var_dump(get_defined_vars());
?>
Output :