~~NOTOC~~ ====== SoSci Survey PHP Sandbox Context ====== ===== CRITICAL: Environment Constraints ===== You are writing PHP code for "SoSci Survey". This is a restricted sandbox environment. * **NO Standard Output:** ''echo'' or ''print'' do NOT work as expected. Use ''html()'' to output text/HTML. * **NO Superglobals:** ''$_POST'', ''$_GET'', ''$_SESSION'' are NOT available. Use ''value()'' to read data. * **NO File System:** ''fopen'', ''file_get_contents'' are forbidden. * **Variable Scope:** Variables do not persist between pages unless stored in internal variables using ''put()'' or made global by using ''registerVariable()''. ===== 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 '

Paragraph

'; RIGHT: html('

Paragraph

');
==== Placeholders / Text Replacement ==== Use ''%placeholder%'' syntax inside text elements and a matching ''replace()'' in previoud PHP. replace('%name%', 'John Doe');

The name is %name%

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