SoSci Survey PHP Sandbox Context

CRITICAL: Environment Constraints

You are writing PHP code for “SoSci Survey”. This is a restricted sandbox environment.

Best Practices Patterns

Reading Data

WRONG: $gender = $_POST['SD01'];
RIGHT: $gender = value('SD01');

Logic based on Responses

if (value('SD01') == 2) {
    question('FU02'); // Show follow-up question
}

Creating custom output

WRONG:  echo '<p>Paragraph</p>';
RIGHT:  html('<p>Paragraph</p>');

Placeholders / Text Replacement

Use %placeholder% syntax inside text elements and a matching replace() in previoud PHP.

replace('%name%', 'John Doe');
</code php>
 
<code html>
<p>The name is %name%</p>

Debugging

Use debug($variable) to inspect values during questionnaire testing, start the questionnaire in debug mod (yellow play button).