fm_set_variable


mixed fm_set_variable ( string $name, string $value )


 

Description


Allows you to store variables which can then be retrieved using fm_get_variable or fm_get_defined_variables.

These variables are different from FileMaker variables in that they are stored at the application level, meaning they can be accessed from any open FileMaker database.

Once a variable is set, it will persist in memory until:

  1. You delete it using fm_unset.
  2. You quit FileMaker.
  3. You stop the plug-in by un-checking it in the preferences.

Note that you can store hidden variables by prefixing the variable name with double underscores “__”. These variables will not be returned by fm_get_defined_variables and thus are considered “hidden”.

The following PHP types can be stored: bool, int, double, string, array. Boolean values will be stored as 1 or 0 and returned as integers.

 

Parameters


name (required)
The name of the variable to set.

value (required)
The value to set.

 

Return


Returns the value that was set.


Errors


There are no errors for this function.

 

Example 1 - Set a string variable
echo fm_set_variable('foo', 'bar');
/*
Returns: bar
*/
Example 2 - Set an array variable
$fb = array(
  'foo' => 'bar',
  'bar' => 'foo'
);
fm_set_variable('fb', $fb);
print_r(fm_get_variable('fb'));
/*
Returns:
Array
(
    [foo] => bar
    [bar] => foo
)
*/

Change Log

VersionDescription
3.0.0Added support for storing bool, int, double and array values.