SoSci Survey
Translations of this page:

Table of Contents


void html(string text)

Outputs HTML code in the questionnaire. This means text can be output or images can be embedded. However, it is more sensible to use HTML for designing layouts (Placing Elements Side by Side).

  • text
    The HTML code which shall be displayed.


  <p>Line breaks are
  not a problem here.</p>


Tip: It is better to use text elements to integrate text, images and lengthy HTML codes. These are created in Text Elements and Labels and dragged into the questionnaire or integrated into a questionnaire page with text(). As a result, the questionnaire remains clear, extended functions (e.g. multilingual surveys or placeholders) are available, and you do not have to worry about using quotation marks.

Note: The PHP functions echo and print() are not released for use in the questionnaire because their output would appear above the questionnaire, rather than in it. Use the function html() instead.

Note: In order to use quotation marks in text which already function as a delimiter, the quotation marks have to be devaluated with a back slash (\). After this, they will not be recognized as a delimiter anymore and displayed properly.

html('<p>This HTML code contains "double quotation marks".</p>');
html("<p>and so does &quot;this&quot;.</p>");
html('<p>This is how it works with single quotation marks</p>');
html('<h1>Hello world!</h1>');  // single quotation marks
html("<h1>Hello world!</h1>");  // double quotation marks 
html('<h1>Hello "world"</h1>');           // right
html("<h1>Hello &quot;world&quot;</h1>"); // even more right
html("<h1>Hello "world"</h1>"); // **Wrong**, because the string
                               // is tagged with double quotation marks and
                               // double quotation marks occur within.
// Spread the string out onto multiple lines - often sensible
// But usually text() is even more sensible 
  <h1>Hello world!</h1>
  <p>How are you, world?</p>

Note: Some words (e.g. “new”) must not appear in PHP code because they hold a particular meaning in PHP. If one of these words appears in your text, and you definitely want to use the command html() instead of a text element, then compile the text with fragments:

// Wrong: cannot be saved for security reasons
html('<p>This is a new car</p>');
// text() does not recognize this restriction
// And this workaround also works
html('<p>This is a ne'.'w car</p>');
en/create/functions/html.txt · Last modified: 24.12.2014 18:26 by alexander.ritter
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
Driven by DokuWiki