ninja_forms_calc_evaluate

Function that takes two variables and our calculation string operator and returns the result.

Description

(int) ninja_forms_calc_evaluate( $op, $value1, $value2 ); 

Returns (int)

value

Parameters (3)

0. $op
The op.
1. $value1
The value1.
2. $value2
The value2.

Usage

  1. if ( !function_exists( 'ninja_forms_calc_evaluate' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'ninja-forms/deprecated/includes/fields/calc.php'; 
  3.  
  4. // The op. 
  5. $op = null; 
  6.  
  7. // The value1. 
  8. $value1 = null; 
  9.  
  10. // The value2. 
  11. $value2 = null; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = ninja_forms_calc_evaluate($op, $value1, $value2); 
  15.  

Defined (1)

The function is defined in the following location(s).

/deprecated/includes/fields/calc.php  
  1. function ninja_forms_calc_evaluate( $op, $value1, $value2 ) { 
  2. switch ( $op ) { 
  3. case 'add': 
  4. return $value1 + $value2; 
  5. break; 
  6. case 'subtract': 
  7. return $value1 - $value2; 
  8. break; 
  9. case 'multiply': 
  10. return $value1 * $value2; 
  11. break; 
  12. case 'divide': 
  13. return $value1 / $value2; 
  14. break;