SoSci Survey
This translation is older than the original page and might be outdated. See what has changed.
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 filter

Modulate questionnaire settings

  • option() – Modulate page settings (Status, Progress-Button)
  • preset() – Presettings for question
  • prepare_input() – Input case for integration in other questions
  • html() – Output of HTML-Code within questionnaire
  • textlink() – Build conjunction between questionnare-text
  • buttonCode() – Create-HTML-Code for Button „forward“ or „backward“
  • buttonHide() – Do not show button automatically at the end page

Functions for randomization

Task depending oFb will give support for several functions for random sampling. Especially between random the sampling with(Random number: random) and the drawing without put back (Urn-drawing: urn) have to be differentiated. Urn-drawing allows to draw multiple correlated Items (e.g. combinative variety combination).

See also Randomisierung.

Advanced programming

See also Variablen in PHP and in question and Items.

Analysis of all data

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

Analysis during interview

  • 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

Graphic account of data

PHP own 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
  • Array-Functions
  • Date and Time
    • date – Format timestamp as date output
    • mktime – Code time measurement into timestamp
    • microtime – Output of microseconds in timestamp
    • time – Output of seconds in timestamp
  • String-Settings
    • htmlentities – Transform all characters which have HTML entities
    • htmlspecialchars – Transform HTML-Syntax-codes (inverted comma, top brackets) into HTML entities
    • ltrim – Delete space at the beginning of strings
    • number_format – Format number after comma
    • rtrim – Delete space at the end of strings
    • str_pad – Fill string length to individual size
    • str_replace – Search part string and replace
    • strlen – Determine string length
    • strtolower – transform sting into lower case
    • strtoupper – Transform string in capitals
    • substr_count – Count frequency of part strings
    • substr – Detect part strings
    • trim – Delete space at beginning and end
    • Also allowed are the functions:

nl2br, str_repeat, str_shuffle, str_word_count, strip_tags, stripos, stristr, strpos, strrev, strripos, strrpos, strstr, substr_replace, wordwrap

  • Drawings (e.g. diagrams)

imagecolorallocate – Use color for graphic

imagecreatetruecolor – New picture in real color (16 Mio.) sings

imagefilledellipse – Draw filled ellipse or circle imagefilledpolygon – Draw filled polygon imagefilledrectangle – Draw filled rectangle imagefilltoborder – Fill picture with color until line

imagepolygon – Draw polygon imagerectangle – Draw rectangle imagesetbrush – Set brush

*imagesetthickness – Set line width

* Continuing allowed functions: image_type_to_extension, image_type_to_mime_type, imagealphablending, imageantialias, imagearc, imagechar, imagecharup, imagecolorallocatealpha, imagecolorat, imagecolorclosest, imagecolorclosestalpha, imagecolorclosesthwb, imagecolordeallocate, imagecolorexact, imagecolorresolve, imagecolorset, imagecopy, imagecopymerge, imagecopymergegray, imagecopyresampled, imagecopyresized, imagedashedline, imagedestroy, imagefilter, imagefontheight, imagefontwidth, imageinterlace, imagepalettecopy, imagerotate, imagesavealpha, imagesettile, imagestringup, imagesx, imagesy, imagetruecolortopalette * Following functions can be used in modified version

  • Miscellaneous
  • intval – Convert Variable into integer value
  • md5 – Compute MD5-hash

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: 13.03.2013 13:20 by benjamin_rubenwolf
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 3.0 Unported
Driven by DokuWiki