error_reporting(E_ALL); $var = 'nothing'; $var1 = &$var; // Adding the &$var1 is where you get your problems. when you execute your function // ref_test(&$var1); echo "before_function:$var1\n"; ref_test($var1); // no error here. echo "after_function 1:$var1\n"; $var = 'something else'; echo "before_function 2:$var1\n"; ref_test(&$var1); // Error here. Don't use it it will be depreciated. echo "after_function 2:$var1\n"; function ref_test(&$var) { echo "before:$var\n"; $var = 'test'; echo "after:$var\n"; } exit;