PHP错误:未定义的变量

can anyone told me what is my error. i know it only notice. All is work well but only show this notice. How to fix this? :

this is the code :

if (isset($_GET['match']) && $_GET['match'] == 'one') {
    $checked_match_one = ' checked="checked"';
    $page_string .= SEP.'match=one';
} else {
    $_GET['match'] = 'all';
    $checked_match_all = ' checked="checked"';
    $page_string .= SEP.'match=all';
}

the error it tell me this :

Notice: Undefined variable: page_string in C:\xampp\htdocs\msigilearnv2\admin\enrollment_attendance.php on line 110
Done writing the list into excel. Download

Simple.Initialize $page_string before using it(before the if statement we can say) like

$page_string = '';
if (isset($_GET['match']) && $_GET['match'] == 'one') {
    $checked_match_one = ' checked="checked"';
    $page_string .= SEP.'match=one';
}

You need to initialize the $page_string variable before the if statement.

Like this..

$page_string = ''; //<--------- Here
if (isset($_GET['match']) && $_GET['match'] == 'one') {
    $checked_match_one = ' checked="checked"';
    $page_string .= SEP.'match=one';

Just add $page_string = ""; in front.

Since you are using the concatenation operator for the variable(for the first time),You should take care of initializing that variable to null, then only you can start any operations (including short hand operators like .=,+=,-=,etc)..

Well, it says so right in the error message: you didn't define $page_string before you tried to read it.

The $page_string .= 'something' operation is shorthand for

$page_string = $page_string . 'something'

In other words, you're trying to read the value of $page_string (which is not defined yet), append 'something to that value, and put the result into $page_string. So, when you try to read the value of an undefined variable PHP does its automagic thing, assumes that the value is supposed to be null, but at least it sends you a notice - because it's suspicious behavior.

Why is it sending the notice? Well, take this piece of code:

$mesage = 'DO NOT ';

if ($something_foo_bar) {
    $message .= 'LAUNCH the nuclear missiles!';
}

That code probably won't do what the developer intended. Oops.