sprintf

  • Returning a formatting string is done nearly identical in Ruby as PHP using the sprintf method.

    PHP

    $s = sprintf("The %s is %d feet tall", "man", 6);
    print $s;
    // => The man is 6 feet tall

    Ruby

    s = sprintf("The %s is %d feet tall", "man", 6)
    puts s
    # => The man is 6 feet tall

    see also

Looking for Rails or PHP web application development, integration, and training?

Rails for PHP is brought to you by Maintainable Software. Get custom web applications and personalized training from the authors of the book and website.