Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use printf function in php

Shulou Source: shulou.com Published: 2022-06-01 03:00:57 10月30日 Update

This article is about how to use the printf function in php. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Printf function

The printf () function returns a formatted string.

Syntax:

Printf (format,arg1,arg2,arg++)

The parameter format is the format of the conversion, starting with a percentage sign ("%") and ending with the converted character.

Here are the possible format values: *%%-returns the percentage symbol

*% b-binary number *% c-character according to ASCII value *% d-signed decimal number *% e-sustainable counting (e.g. 1.5e+3) *% u-unsigned decimal number *% f-floating point number (local settings aware) *% F-floating point number (not local settings aware) *% o-octal number *% s-string *% x- Hexadecimal number (lowercase) *% X-hexadecimal number (uppercase) arg1 Parameters such as arg2, arg++, etc., are inserted at the percent sign (%) symbol in the main string. The function is executed step by step, inserting arg1 in the first% symbol, arg2 at the second% symbol, and so on.

If the% symbol is more than the arg parameter, you must use a placeholder. After the placeholder is inserted with the% symbol, it consists of numbers and "\ $".

You can use numbers to specify the parameters displayed. For more information, please see the example.

Thank you for reading! This is the end of the article on "how to use the printf function in php". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Tags: Symbols functions characters parameters strings percentages content hexadecimal decimal letters numbers more formats points percentages articles decimal good practical and so on Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Redmi Shulou Information Apple Microsoft