
Originally Posted by
DigitalShadow
if the reason text includes a
it breaks the submission
Is there a fix?
No bug or error. This is because this is how PHP works. The define files are probably like this:
PHP Code:
define('SOME_CONSTANT_DEFINED', 'The text that is going to be used to act as the definition.');
When you put in a ' in that second part (after the comma), you're breaking the define and PHP does not know how to handle it. The easiest way to fix this, is to remember that whenever you're working with single quotes or double quotes, that you should use a backslash (\) immediately before. To that end, if you plan on using the backslash itself, you need to use a double backslash instead (\\). The single backslash tells php that the character following the slash is a "special" character. This include "\n" which causes a newline break in plain text (or preformatted <PRE> text) or "\t" which inserts a tab in the same sense. \' indicates to PHP that it should output a single quote and \" should output a double quote.
Leaving that off, you get something like this.
PHP Code:
define('SOME_CONSTANT_DEFINED', 'You can't just insert a single quote.');
Notice how part of the text that is supposed to be defining the constant is red and the other part is blue. The part that is red (without the quote) will be defined into the constant, but the part in blue will generate an error since this is not correct syntax. Since the ' are being used to delimit the definition, PHP is expecting a ' to delimit the text. Without escaping it, PHP will interpret the first ' as the end of the string to define while PHP tosses its hand up figuratively since it doesn't know how to handle the blue.
NOTE: If the string is being delimited with a double quote, you can safely use the single quote inside a set of double quotes safely. As well as vice versa. Example:
PHP Code:
define('SAMPLE_CONSTANT_2', "This string is being delimited with double quotes, so I can use ' without using a backslash safely.");
PHP Code:
define('SAMPLE_CONSTANT_3', 'This string is being delimited with single quotes, so I can use " without using a backslash safely.');
Bookmarks