pods_var

Return a variable (if exists).

Description

pods_var( (string) $var = 'last', (string) $type = 'get', (constant) $default = null, (constant) $allowed = null, (constant) $strict = false, (constant) $casting = false, (string) $context = 'display' ); 

Parameters (7)

0. $var — Optional. (string) => 'last'
The variable name or URI segment position
1. $type — Optional. (string) => 'get'
Super globals, url/url-relative, constants, globals, options, transients, cache, user data, Pod field values, dates
2. $default — Optional. (constant) => null
The default value to set if variable doesn't exist
3. $allowed — Optional. (constant) => null
The value(s) allowed
4. $strict — Optional. (constant) => false
Only allow values (must not be empty)
5. $casting — Optional. (constant) => false
Whether to cast the value returned like provided in $default
6. $context — Optional. (string) => 'display'
All returned values are sanitized unless this is set to raw

Usage

  1. if ( !function_exists( 'pods_var' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'pods-custom-content-types-and-fields/includes/data.php'; 
  3.  
  4. // The variable name or URI segment position 
  5. $var = 'last'; 
  6.  
  7. // (optional) Super globals, url/url-relative, constants, globals, options, transients, cache, user data, Pod field values, dates 
  8. $type = 'get'; 
  9.  
  10. // (optional) The default value to set if variable doesn't exist 
  11. $default = null; 
  12.  
  13. // (optional) The value(s) allowed 
  14. $allowed = null; 
  15.  
  16. // (optional) Only allow values (must not be empty) 
  17. $strict = false; 
  18.  
  19. // (optional) Whether to cast the value returned like provided in $default 
  20. $casting = false; 
  21.  
  22. // (optional) All returned values are sanitized unless this is set to 'raw' 
  23. $context = 'display'; 
  24.  
  25. // NOTICE! Understand what this does before running. 
  26. $result = pods_var($var, $type, $default, $allowed, $strict, $casting, $context); 
  27.  

Defined (1)

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

/includes/data.php  
  1. function pods_var( $var = 'last', $type = 'get', $default = null, $allowed = null, $strict = false, $casting = false, $context = 'display' ) { 
  2.  
  3. if ( 'raw' == $context ) { 
  4. $output = pods_v( $var, $type, $default, $strict, array( 'allowed' => $allowed, 'casting' => $casting ) ); 
  5. else { 
  6. $output = pods_v_sanitized( $var, $type, $default, $strict, array( 'allowed' => $allowed, 'casting' => $casting ) ); 
  7.  
  8. return $output; 
  9.