---
title: "What is the use of sprintf() function?"  
description: "What is the use of sprintf() function?"  
author: "Anonymous User"  
published: 2011-03-18  
updated: 2020-09-18  
canonical: https://www.mindstick.com/interview/471/what-is-the-use-of-sprintf-function  
category: "php"  
tags: ["php"]  
reading_time: 1 minute  

---

# What is the use of sprintf() function?

**The sprintf() function writes a formatted string to a variable.**

The arg1, arg2, ++ parameters will be inserted at percent (%) signs in the main string. This function works "step-by-step". At the first % sign, arg1 is inserted, at the second % sign, arg2 is inserted, etc.\

## Answers

### Answer by Anonymous User

**The sprintf() function writes a formatted string to a variable.**

The arg1, arg2, ++ parameters will be inserted at percent (%) signs in the main string. This function works "step-by-step". At the first % sign, arg1 is inserted, at the second % sign, arg2 is inserted, etc.\


---

Original Source: https://www.mindstick.com/interview/471/what-is-the-use-of-sprintf-function

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
