⊗ppPmSFIP 155 of 447 menu

Outputting a String with Insertion in PHP

printf sprintf

Given a variable:

<?php $price = 19.99; ?>

Output the price in the following format:

'price: 19.99

Given variables:

<?php $name = "John"; $age = 25; ?>

Output the string in the following format:

'Name: John, Age: 25 years'

Given variables:

<?php $name = 'John'; $score = 95; ?>

Output the following string:

'student John scored 95 points'

Given variables:

<?php $product = "Laptop"; $price = 1299.99; $discount = 15; ?>

Output the product information in the format:

'Product: Laptop | Price: $1299.99 | Discount: 15%'

Given variables:

<?php $x = 10; $y = 20; $z = 30; ?>

Output the result in the format:

'Sum: 10 + 20 + 30 = 60'

Given variables:

<?php $day = 15; $month = "March"; $year = 2023; ?>

Output the date in the format:

'Date: March 15, 2023'
English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline