tomasr
tomasr

Reputation: 367

sprintf - Unknown format specifier "P"

I need to sometimes display the text of the discount directly and sometimes replace the numerical value. When the text is generated the system will do something like "Discount is %s". When filling out the discount, the operator will write "Discount is 10%".

I have:

sprintf($text, $value . ' %')

For generated text, the number is replaced (sprintf("Discount is %s", 10 . ' %')), but for manually typed text sprintf("Discount is 15 %", 15 . ' %') I get an error in PHP 8.2:

Unknown format specifier "P"

In the PHP7.4 version, there was no error even with the manually created text. How to solve the situation? I need for manually entered text to have sprintf ignore the replacement (or replace only %s) or recognize that it is automatically generated text.

Upvotes: 0

Views: 161

Answers (0)

Related Questions