alex848 Posted April 14, 2011 Share Posted April 14, 2011 $age = 18; //$age =___; //not working say error. unset($age); //working whats wrong? thanks Link to comment https://forums.phpfreaks.com/topic/233708-unset-variable/ Share on other sites More sharing options...
Muddy_Funster Posted April 14, 2011 Share Posted April 14, 2011 Nothing? If you want to unset a variable you use unset, what's the problem? You want to make the value of $age = ___? put it in quotes like you would any other string value. Link to comment https://forums.phpfreaks.com/topic/233708-unset-variable/#findComment-1201538 Share on other sites More sharing options...
monkeytooth Posted April 14, 2011 Share Posted April 14, 2011 age = __ is a string and not an INT would need to be wrapped in quotes.. where as 18 can be a string or int, and in the event of it being an INT you dont need quotes.. Link to comment https://forums.phpfreaks.com/topic/233708-unset-variable/#findComment-1201540 Share on other sites More sharing options...
monkeytooth Posted April 14, 2011 Share Posted April 14, 2011 also unset I believe applies to data that is array based. if you want to clear the value of a variable just do $age = ""; Link to comment https://forums.phpfreaks.com/topic/233708-unset-variable/#findComment-1201542 Share on other sites More sharing options...
alex848 Posted April 14, 2011 Author Share Posted April 14, 2011 Thank you all. Maybe is $age = __ ; error in book(without quotes in book), anyway $age = ""; nice. Link to comment https://forums.phpfreaks.com/topic/233708-unset-variable/#findComment-1201568 Share on other sites More sharing options...
KevinM1 Posted April 14, 2011 Share Posted April 14, 2011 Keep in mind, technically $age isn't unset by doing that. It still exists, and contains a value of an empty string. Link to comment https://forums.phpfreaks.com/topic/233708-unset-variable/#findComment-1201570 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.