Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to replace sprintf in php

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

Editor to share with you how to replace sprintf in php, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Php sprintf to achieve replacement methods: 1, to create a PHP sample file; 2, through "sprintf (" There are% u million cars in% s. ", $number,$str);" to replace the specified symbol.

This article operating environment: Windows7 system, PHP7.1 version, Dell G3 computer.

The sprintf () function writes the formatted string to the variable.

The arg1, arg2, + + parameters are inserted at the percent sign (%) symbol in the main string. This function is executed step by step. At the first% symbol, insert arg1, at the second% symbol, insert arg2, and so on.

Note: if the% symbol is more than the arg parameter, you must use a placeholder. Placeholders are located after the% symbol and consist of numbers and "\ $". See example 2.

Hint: related functions: printf (), vprintf (), vsprintf (), fprintf () and vfprintf ()

Example

Replace the percent sign (%) sign with a variable passed as a parameter:

Running result:

There are 2 million cars in Shanghai.

Sprintf syntax:

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

The above is all the content of the article "how to replace sprintf in php". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report