Too many " or '
I seriously suck at getting the quotes and quotation marks correctly. is there a rule that would help me easily remember?
开发者_Go百科echo "<option value='".$data['recordc']."' . "selected=selected>" '". data['recordc'] ."' . "</option>";
You could easily fix the quotes problem with a decent editor that has syntax highlighting (even StackOverflow's basic highlighting quickly shows where you went wrong) but that is still a horrible mess to read.
Most of the time if you find yourself outputting too much HTML in an echo
you are probably best served to do it in a cleaner way, like breaking out of PHP. I would do at the very least:
printf('<option value="%1$s" selected=selected>%1$s</option>', $data['recordc']);
In general you can use this instead:
echo "<option value=\"$data[recordc]\" selected=selected>$data[recordc]</option>";
which is a little easier to read. Array keys don't need to be quoted when used inside a string.
In this case, paolo's printf
method is nice since the variable is reused
精彩评论