Public Parameters and Functions

Creating an open parameter makes it readable and writeable from an external scope. In some cases it may be required to allow read access of a variable from outside without the effect that the parameter can be changed unexpectedly. Or one needs to define a function that can be called from outside. These are typical requirements of a library that is imported as package into another script. The public keyword defines that a variable or function is intended for external access.

The public is simply placed in front of the variable or function declaration:

Example

public int i
public function f()
{
  echo( "Function f() called" )
}

Public variable or function declarations must appear in a global scope, i.e. they may not be declared inside statement block.

Appart from that, public variables and functions can just be used like any other variables or functions inside the script.