webdesignmad Posted February 18, 2012 Share Posted February 18, 2012 Hi. I installed xampp to practice php scripting. Until today, it has worked fine, but now it says: Notice: Undefined variable: text in E:\xampp\htdocs\Experiments\Tutorial\HelloWorld.php on line 6 What can I do to fix this? I'm told that variable don't need to be defined before being initialized, but that doesn't really mean much to me! Please help Quote Link to comment https://forums.phpfreaks.com/topic/257233-xampp-notice-undefined-variable/ Share on other sites More sharing options...
jcbones Posted February 18, 2012 Share Posted February 18, 2012 Variables do not need to be defined before being initialized, but they do need to be defined before being called for use. You are trying to use a variable called text, without it being set. Without the code, there is no way to help you though. $str = 'This is a string.'; //defined if($text) { //text is not defined, and you will get a notice. $text = 'More text.'; //text is now defined. } if(isset($fell_down)) { //fell down is not defined, but isset will keep it from throwing a notice. (empty will too). Quote Link to comment https://forums.phpfreaks.com/topic/257233-xampp-notice-undefined-variable/#findComment-1318561 Share on other sites More sharing options...
webdesignmad Posted March 8, 2012 Author Share Posted March 8, 2012 Ah thanks very much. I've been looking for a solution to that for ages! Quote Link to comment https://forums.phpfreaks.com/topic/257233-xampp-notice-undefined-variable/#findComment-1325241 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.