--- layout: default title: Documentation ---
This Documentation gives you a quick reference about all classes and methods that comes with the basic framework package.
Bind value to framework variable
setting framework variables
{% highlight php startinline %} F3::set('a',123); // a=123, integer F3::set('b','c'); // b='c', string F3::set('c','whatever'); // c='whatever', string F3::set('d',TRUE); // d=TRUE, boolean {% endhighlight %}setting arrays
{% highlight php startinline %} F3::set('hash',array( 'x'=>1,'y'=>2,'z'=>3 ) ); // dot notation is also possible F3::set('hash.x',1); F3::set('hash.y',2); F3::set('hash.z',3); {% endhighlight %}If the persist parameter is TRUE, and the F3 CACHE is enabled, the var is going to be cached.
You can cache strings, arrays and all other types - even complete objects. F3::get() will load them automatically.
By default, the resolve parameter allows you to use the F3 specific syntax in getting and setting vars.
{% highlight php startinline %} F3::set('{{ "{{@b" }}}}','wherever'); // c='wherever' F3::set('{{ "{{@b" }}}}','{{ "{{@a+1" }}}}'); // c='124' F3::set('{{ "{{@b" }}}}',F3::get('a')+1); // c=124 F3::set('color','green'); F3::set('car','this car is {{ "{{@color" }}}}.'); // car='this car is green.' {% endhighlight %}Retrieve value of framework variable and apply locale rules
to get a previously saved framework var use:
{% highlight php startinline %} F3::set('c','whatever'); F3::get('c'); // [ string ] = 'whatever' {% endhighlight %}you can also resolve other vars
{% highlight php startinline %} F3::set('foo','bar'); F3::set('bar','nice'); F3::get('{{ "{{@foo" }}}}'); // returns: nice {% endhighlight %}Since F3 version 2.0.13 it is also possible to use expressions along with variable array keys. Using these operations makes it easier to access i.e. the next and previous keys of an array like this:
{% highlight php startinline %} F3::set('myarray', array( 0 => 'value_0', 1 => 'value_1', )); F3::set('akey',0); F3::get('myarray[@akey+1]'); // returns: value_1 {% endhighlight %}Unset framework variable
If you want to remove a framwork variable from memory, you can clear it like this:
{% highlight php startinline %} F3::clear('foobar'); F3::clear('myArray.param1'); // removes key `param1` from array `myArray` F3::clear('SESSION'); // destroys the user SESSION {% endhighlight %}Return TRUE if framework variable has been assigned a value
To find out if a variable has been previously defined:
{% highlight php startinline %} F3::set('foo','var'); F3::set('var',1234); F3::exists('var'); // true F3::exists('{{ "{{@foo" }}}}'); // true F3::exists('bar'); // false {% endhighlight %}Return TRUE if specified string is a valid framework variable name
Usage:
{% highlight php startinline %} F3::valid('var'); // true F3::valid('var-1'); // error F3::valid('*as'); // error F3::valid('Gemüse'); // error {% endhighlight %}Multi-variable assignment using associative array
With a key=>value paired associative array you can define multiple vars.
{% highlight php startinline %} F3::mset(array( 'var1'=>'value1', 'var2'=>'value2', 'var3'=>'value3', )); F3::get('var1'); // value1 F3::get('var2'); // value2 F3::get('var3'); // value3 {% endhighlight %}Using the prefix argument, you can append all key names.
{% highlight php startinline %} F3::mset(array( 'var1'=>'value1', 'var2'=>'value2', 'var3'=>'value3', ), 'pre_'); F3::get('pre_var1'); // value1 F3::get('pre_var2'); // value2 F3::get('pre_var3'); // value3 {% endhighlight %}Determine if framework variable has been cached
Flatten array values and return as CSV string
Split pipe-, semi-colon, comma-separated string
Returns -1 if the specified number is negative, 0 if zero, or 1 if the number is positive
Get framework variable reference/contents
If you set the set argument to false, it basically behaves like F3::get() and it only returns a read-only variable.
Copy contents of framework variable to another
Concatenate string to framework string variable
Usage:
{% highlight php startinline %} F3::set('var','hello'); F3::concat('var',' world'); echo F3::get('var'); // output: hello world {% endhighlight %}Format framework string variable
Usage:
{% highlight php startinline %} $count = 5; $location = 'tree'; $format = 'There are %d apes on the %s.'; echo F3::sprintf($format, $count, $location); // There are 5 apes on the tree. {% endhighlight %}Add keyed element to the end of framework array variable
Usage:
{% highlight php startinline %} $stock = array('apple'=>12,'cherry'=>4,'banana'=>8); F3::set('fruits',$stock); F3::set('pineapple',3); F3::append('fruits','peach',20); print_r(F3::get('fruits')); /* output: Array ( [apple] => 12 [cherry] => 4 [banana] => 8 [peach] => 20 ) */ {% endhighlight %}You can also resolve other vars within the arguments, to easily switch the processed data, without changing code.
{% highlight php startinline %} F3::set('stock','fruits'); F3::set('newFruit','pineapple'); F3::append('{{ "{{@stock" }}}}','{{ "{{@newFruit" }}}}',20); print_r(F3::get('{{ "{{@stock" }}}}')); /* output: Array ( [apple] => 12 [cherry] => 4 [banana] => 8 [peach] => 20 [pineapple] => 20 ) */ {% endhighlight %}Swap keys and values of framework array variable
Usage:
{% highlight php startinline %} F3::set('data',array( 'foo1'=>'bar1', 'foo2'=>'bar2', 'foo3'=>'bar3', )); F3::flip('data'); print_r(F3::get('data')); /* output: Array ( [bar1] => foo1 [bar2] => foo2 [bar3] => foo3 ) */ {% endhighlight %}Merge one or more framework array variables
Usage:
{% highlight php startinline %} F3::set('data1',array( 'foo1'=>'bar1', 'foo2'=>'bar2', )); F3::set('data2',array( 'foo3'=>'bar3', )); print_r(F3::merge(F3::get('data1'),'data2',array('foo4'=>'bar4'))); /* output: Array ( [foo1] => bar1 [foo2] => bar2 [foo3] => bar3 [foo4] => bar4 ) */ {% endhighlight %}Add element to the end of framework array variable
Usage:
{% highlight php startinline %} F3::set('fruits',array( 'apple', 'banana', 'peach', )); F3::push('fruits','cherry'); print_r(F3::get('fruits')); /* output: Array ( [0] => apple [1] => banana [2] => peach [3] => cherry ) */ {% endhighlight %}Remove last element of framework array variable and return the element
Usage:
{% highlight php startinline %} F3::set('fruits',array( 'apple', 'banana', 'peach' )); F3::pop('fruits'); // returns "peach" print_r(F3::get('fruits')); /* output: Array ( [1] => apple [2] => banana ) */ {% endhighlight %}Add element to the beginning of framework array variable
Usage:
{% highlight php startinline %} F3::set('fruits',array( 'apple', 'banana', 'peach' )); F3::unshift('fruits','cherry'); print_r(F3::get('fruits')); /* output: Array ( [0] => cherry [1] => apple [2] => banana [3] => peach ) */ {% endhighlight %}Remove first element of framework array variable and return the element
Usage:
{% highlight php startinline %} F3::set('fruits',array( 'apple', 'banana', 'peach' )); F3::shift('fruits'); // returns "apple" print_r(F3::get('fruits')); /* output: Array ( [0] => banana [1] => peach ) */ {% endhighlight %}Convert special characters to HTML entities using globally-defined character set
The basic usage uses `htmlspecialchars` to convert symbols like `& " ' < >` based on your applications ENCODING (default: utf-8):
{% highlight php startinline %} echo F3::htmlencode("we want 'sugar & candy'"); // output: we <b>want</b> 'sugar & candy' {% endhighlight %}If that's not enough, set the all argument `true`, and it will encode even more chars using `htmlentities`.
{% highlight php startinline %} echo F3::htmlencode("§9: convert symbols & umlauts like ä ü ö",true); //output: §9: convert symbols & umlauts like ä ü ö {% endhighlight %}Convert HTML entities back to their equivalent characters
For decoding more special chars like entities and umlauts, set the all argument to `true`.
{% highlight php startinline %} echo F3::htmldecode("§9: convert symbols & umlauts like ä ü ö",true); //output: §9: convert symbols & umlauts like ä ü ö welcome! {% endhighlight %}Convert Windows double-backslashes to slashes; Also for referencing namespaced classes in subdirectories
Convert PHP expression/value to compressed exportable string
Generate Base36/CRC32 hash code
Convert hexadecimal to binary-packed data
Convert binary-packed data to hexadecimal
Convert engineering-notated string to bytes
Convert from JS dot notation to PHP array notation
Send HTTP status header. Return text equivalent of status code
Retrieve HTTP headers
Send HTTP header with expiration date ( seconds from current time )
Reroute to specified URI
Assign handler to route pattern
Provide REST interface by mapping URL to object/class
Call route handler
Process routes based on incoming URI
Remove HTML tags ( except those enumerated ) to protect against XSS/code injection attacks
Call form field handler
Default filter id is FILTER_UNSAFE_RAW. Other useful filter might be: FILTER_VALIDATE_EMAIL, FILTER_VALIDATE_URL, FILTER_VALIDATE_IP. To get a list of all supported filter use print_r( filter_list() );
The ops argument describes options, used by the filter, if that filter supports options.
Transmit a file for downloading by HTTP client
If kilobytes per second is specified, output is throttled ( bandwidth will not be controlled by default ).
It returns TRUE if successful, FALSE otherwise. Support for partial downloads is indicated by third argument. Download as attachment if fourth argument is TRUE
Lock-aware file reader
Lock-aware file writer. Returns number of bytes written or false. Use `append` arguement to just add data to the end of the file, instead of writing/overwriting the whole file.
Create folder; Trigger error and return FALSE if script has no permission to create folder in the specified path
Return runtime performance analytics
It contains information about memory usage, elapsed time and caching.
Perform test and append result to TEST global variable
Display default error page; Use custom page if found
Mock environment for command-line use and/or unit testing. It simulates an incoming HTTP request for a URL.
Intercept instantiation of objects in undefined classes
Configure framework according to INI-style file settings Cache auto-generated PHP code to speed up execution
Execute callback as a mutual exclusion operation.
Return instance of child class
onLoad event handler ( static class initializer )
Sniff headers for real IP address
Render user interface
Evaluate template expressions in string
Return TRUE if IP address is local or within a private IPv4 range
Bootstrap code
Execute shutdown function
Clean and repair HTML
Saves current object values to the database. Axon decides whether to created or update the entry.
{% highlight php startinline %} $ax = new Axon('users'); $ax->name = 'John'; $ax->lastname = 'Doe'; $ax->save(); {% endhighlight %}Checks whether the Axon object is hydrated or not. Hydrated = load() / find() was successfull.
Deletes the current hydrated object from the database.
Finds all entries depending on the condition and returns an object
Equal to find(), but returns an array
Equal to find(), but returns only the first retsult
Equals to afind(), but returns only the first retsult
found() returns the number of records found by the condition or an already issued found() / load().
Dehydrates (clears) the current object.
Equal to findone(), but you can choose the nth record.
Returns the next record.
Returns the previous record.
Hydrate Axon with elements from array variable.
Populate array variable with Axon properties.