/    Sign up×
Community /Pin to ProfileBookmark

hi,
printf takes a string to be formatted as its first parameter. just wondering is there any way to store that parameter in a variable and just use the variable as the first placeholder??

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@tracknutJul 27.2021 — Sure, that field is a string like any other, so for example:
<i>
</i>$format = "&lt;p&gt;The number is &lt;em&gt;%d&lt;/em&gt;&lt;/p&gt;";
printf ($format,42);
Copy linkTweet thisAlerts:
@NogDogJul 27.2021 — And just because you might want to get all functional about it, you can even provide a function call:
[code=php]
printf(format(), 42);

function format() {
return '<p>The number is <em>%d</em></p>';
}
[/code]


:)
Copy linkTweet thisAlerts:
@tikenowuauthorDec 10.2021 — thanks a lot [;)](https://safepornsites.pro/)
×

Success!

Help @tikenowu spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...