6

The following code:

var_dump(check_markup('This is a test', 'plain_text'));

outputs:

string(22) "<p>This is a test</p>"

Why does it do this?

1
  • I was looking in drupal and it looks like it does this: Display any HTML as plain text Convert URLs into links Convert line breaks into HTML (i.e. <br> and <p>) May 18 '12 at 13:23
9

check_markup() will:

Run all the enabled filters on a piece of text.

Since one of those filters will probably be the HTML corrector, you'll get the <p></p> tags wrapping your text string.

7

It depends from the input filters enabled for the input format. By default, for the "Plain text" input format, they are the following ones.

screenshot

"Convert URLs into links," and "Convert line breaks into HTML" add HTML tags into the text.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.