Home > Backend Development > PHP Tutorial > In PHP, what do %s and %d mean?

In PHP, what do %s and %d mean?

jacklove
Release: 2023-03-27 13:00:02
Original
6135 people have browsed it

In PHP, you often encounter %s and %d. This article will introduce what %s and %d mean?

Parameters used by PHP sprintf() function

printf - Output formatted string

sprintf() function writes the formatted string into a variable.

%% - Returns the percent symbol

%b - Binary number

%c - Character according to ASCII value

%d - Signed decimal number

%e - Continuous notation (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 letters)

%X - Hexadecimal number (uppercase letters)

<?php
$str = "Hello";
$number = 123;
$txt = sprintf("%s world.  number %d",$str,$number);
echo $txt;
?>
Copy after login

Output:

Hello world. number 123

this This article will explain what %s and %d mean. For more related content, please pay attention to the PHP Chinese website.

Related recommendations:

think php5 multi-table query paging to get the total number of code methods

php commonly used functions processing functions Analysis

PHP The simplest way to verify logged in users (basic form user verification)

The above is the detailed content of In PHP, what do %s and %d mean?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template