为什么sprintf()在这种情况下不起作用?

I'm using sprintf() in PHP but it displays nothing on the page.

Here's what I'm doing:

$lang['request_paragraph']="Please check your email for a message from %s (%s). This message contains instructions for initiating the issuance of a new password for your participant number. If you did not receive the email message from %s within 10-15 minutes, please make sure that your email provider does not have a spam filter that is blocking our email from reaching your Inbox. You will not be able to receive email from us if your email provider is using a mail-blocking device. Click on the button below to send the validation email again if it appears to have been blocked or never received. You will only be able to re-send the validation email 3 more times.";

$company="Company Name";

$admin_email="admin@company.com";

sprintf($lang['request_paragraph'],$company,$admin_email,$company);

Doing an echo on each individual string displays each string correctly, so what am I doing wrong?

I need to use sprintf() because I'm working with language files and it makes it much more simple than splitting the paragraph into pieces in the language definitions.

sprintf returns a variable (a string).

You need printf

edit to echo sprintf($lang['request_paragraph'],$company,$admin_email,$company);

You need to echo the sprintf too.

sprintf function just do the sequential replace of placeholder (type specifiers) characters in the first string argument and does not echo,print or output anything but return the formatted string.

so your line of code:

sprintf($lang['request_paragraph'],$company,$admin_email,$company);

will be replaced by:

echo sprintf($lang['request_paragraph'],$company,$admin_email,$company);

or

print(sprintf($lang['request_paragraph'],$company,$admin_email,$company));