Jump to content

XAMPP - "Notice: Undefined variable"


webdesignmad

Recommended Posts

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

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

  • 3 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.