Include single quote to string

后端 未结 1 1101
渐次进展
渐次进展 2021-01-20 05:14

I want to have a dropdown from MySQL data where I want , including the two single quotes to pass it into a que

相关标签:
1条回答
  • 2021-01-20 05:21

    From the MySQL manual:

    There are several ways to include quote characters within a string:

    • A “'” inside a string quoted with “'” may be written as “''”.

    • A “"” inside a string quoted with “"” may be written as “""”.

    • Precede the quote character by an escape character (“\”).

    • A “'” inside a string quoted with “"” needs no special treatment and need not be doubled or escaped. In the same way, “"” inside a string quoted with “'” needs no special treatment.

    When coding in php, remember to use \\ in a string literal to get a single \ in the string value.

    If you want to escape the quote in an HTML attribute, replace the ' with ". Alternatively, quote the attribute value with ". These are the techniques to use regardless of where the string value came from. See this thread.

    0 讨论(0)
提交回复
热议问题