This may sound strange, but here goes.
I like using this technique of building a string in php
printf(__('This is %1$s, this is %2$s'), myFunction1(), myFunction2());
Obviously this directly prints the results whenever the function is called, but I would like to use this technique to just build a string, and then use it later elsewhere.
Is this possible?
Thanks guys.
printf() is not printing any thing because the string mentioned is empty and in if it will also return the number of character printed which is 0. So it will proceed in else block instead of if. Here a[] is empty and in if statement we are printing a[], hence nothing will be printed.
The most basic printing functions would be puts and putchar which print a string and char respectively. f is for formatted. printf (unlike puts or putchar ) prints formatted output, hence printf.
C++ printf is a formatting function that is used to print a string to stdout.
Printf is not the thing being buffered, it's stdio, so all similar functions will behave in the same way. To demonstrate the buffering, all you have to do is printf a lot of characters, usually more than 1024, and printf will print as you will have exceeded the maximum buffer length and it will automatically fflush.
Use sprintf
to do this:
$var = sprintf(__('This is %1$s, this is %2$s'), myFunction1(), myFunction2());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With