WP_CLI::print_value()
Display a value, in various formats
Method of the class: WP_CLI{}
No Hooks.
Return
null
. Nothing (null).
Usage
$result = WP_CLI::print_value( $value, $assoc_args );
- $value(mixed) (required)
- Value to display.
- $assoc_args(array)
- Arguments passed to the command, determining format.
Default: []
WP_CLI::print_value() WP CLI::print value code WP-CLI 2.8.0-alpha
public static function print_value( $value, $assoc_args = [] ) { if ( Utils\get_flag_value( $assoc_args, 'format' ) === 'json' ) { $value = json_encode( $value ); } elseif ( Utils\get_flag_value( $assoc_args, 'format' ) === 'yaml' ) { $value = Spyc::YAMLDump( $value, 2, 0 ); } elseif ( is_array( $value ) || is_object( $value ) ) { $value = var_export( $value, true ); } echo $value . "\n"; }