Translations of this page:
 

PHP-Functions

This chapter shows you the main functions of PHP-Code Elements which can be used. The Introduction in PHP-Code will help you to integrate all PHP functions for your questionnaire.

At the very end of this page will be a helpful information how the documentation of the PHP-functions can be read: Function in Detail

Basic Fuctions for Filtering, Questions and Text

See also filter questions und filters.

  • value() – Use answer of participant, e.g. for a filter question
  • goToPage() – Jump to another page immediately
  • repeatPage() – Show recent page again
  • redirect() – Redirect the respondent to a different website
  • question() – Display a question within the questionnaire
  • text() – Display a text element within the questionnaire
  • debug() – Show content of a data or PHP variable

Modify How to Display a Questionnaire Page

  • option() – Modify page display settings (buttons, progress bar)
  • preset() – Preset a response for a question
  • markFail() – Set the marker “response missing” for an input
  • prepare_input() – Prepare an input to be shown within another question
  • html() – Output of HTML-Code within questionnaire
  • textlink() – Create a hyperlink that shows a text element in a pop-up window
  • buttonToPage() – Button to jump within the questionnaire
  • buttonCode() – Create-HTML-Code for next/back button
  • buttonHide() – Do not show back/next buttons at the page's bottom
  • library()​ – Make a JavaScript or PHP library available
  • pageCSS() – Add CSS instructions to a single questionnaire page
  • pagehead – Store meta-information about the questionnaire page

Functions for Randomization

SoSci Survey supports several functions for random sampling or random group assignment (Randomization).

  • put() – Save a value in the data set
  • random() – Dice a random number (with replacement)
  • random_p() – Random number in correlation to likelihood
  • random_items() – Randomly select items from a list
  • randomUse() – Storing slips of paper from a random number generator
  • urnDraw() – Draw out from urn (random selection without replacement)
  • urnPutAway() – Put away the chit drawn via urnDraw()
  • urnStatus() – Retrieve current status of an urn

Advanced Programming

Coordination of Several Questionnaires

Databank for Contents

  • dbGet() – Read data from date base
  • dbKeys() – List key for data base
  • dbSet() – Safe data in data base
  • dbTouch() – Refresh time-stamp for data base entry

Analysis of all data

  • statistic() – Simple statistical analysis of all data
  • diagram() – Simple diagram (e. g. frequency) for all analyzed data

Analyses and Data Handling During an Interview

  • answers() – Show a question including the respondent's answers
  • answersOption() – Adjust display of answers via answers() or answersPrint()
  • answersPrint() – Display all questions of a questionnaire segment including the respondent's answers
  • valueSum() – Compute sum over scale or variables
  • valueMean() – Compute mean over scale or variable
  • valueSD() – Compute standard deviation over scale or variable
  • valueVar() – Compute variance over scale or variable
  • convertDateTime() – Convert date/time texts (strings) and timestamps

Data Visualization

Respondent and Mailing Management

PHP-internal functions

PHP provides a number of helpful functions, which can easily be used during questionnaire PHP Manual documented.

  • Useful functions in general
    • implode - Array-Fusion of elements to string
    • explode - Split string into array
    • preg_split - Split string with regular expression into array
  • Mathematical functions
    • round - Circular from comma
    • ceil - Round up
    • floor - Round down
    • abs - Find amount of number

Restricted Functions

Some functions pose a security risk or do not work as expected in the context of the questionnaire. Alternatives are listed below. If you need additional features, please let SoSci Survey know.

Detailed Functions

Reference-syntax for each function, e.g.:

void set(mixed Value, [string Memory])

This reference-syntax describes the argumentation of functions and it's data type.

  • At the beginning return function of data type is shown void, meaning: function is acting but does not return values.
  • Arguments listed in braces. Optional arguments in angled braces. Function set() has o have at least one argument Value than it is allowed to use another (second) argument Memory .
  • Type of data stands in front of argument:
    • mixed means different types of data are allowed
    • int is a number
    • string text with inverted comma
    • array List of values (Arrays)
en/create/functions.txt · Last modified: 27.11.2020 21:37 by sophia.schauer
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
Driven by DokuWiki