Back to Text class

Method printf

public static mixed
printf
(mixed $string)
Passes a string thru an printf.
Parameters
  • string $string The format string.
Returns
  • mixed
Since
  • 1.7.0
Class: Text
Project: Joomla

Method printf - Source code

/**
 * Passes a string thru an printf.
 *
 * Note that this method can take a mixed number of arguments as for the sprintf function.
 *
 * @param   string  $string  The format string.
 *
 * @return  mixed
 *
 * @since   1.7.0
 */
public static function printf($string)
{
    $lang = Factory::getLanguage();
    $args = \func_get_args();
    $count = \count($args);
    if (\is_array($args[$count - 1])) {
        $args[0] = $lang->_($string, \array_key_exists('jsSafe', $args[$count - 1]) ? $args[$count - 1]['jsSafe'] : false, \array_key_exists('interpretBackSlashes', $args[$count - 1]) ? $args[$count - 1]['interpretBackSlashes'] : true);
    } else {
        $args[0] = $lang->_($string);
    }
    return \call_user_func_array('printf', $args);
}