Udskrivning af streng med indsættelse i PHP
Givet variabel:
<?php
$price = 19.99;
?>
Udskriv prisen i følgende format:
'price: 19.99
Givet variable:
<?php
$name = "John";
$age = 25;
?>
Udskriv strengen i følgende format:
'Name: John, Age: 25 years'
Givet variable:
<?php
$name = 'John';
$score = 95;
?>
Udskriv følgende streng:
'student John scored 95 points'
Givet variable:
<?php
$product = "Laptop";
$price = 1299.99;
$discount = 15;
?>
Udskriv produktinformation i formatet:
'Product: Laptop | Price: $1299.99 | Discount: 15%'
Givet variable:
<?php
$x = 10;
$y = 20;
$z = 30;
?>
Udskriv resultatet i formatet:
'Sum: 10 + 20 + 30 = 60'
Givet variable:
<?php
$day = 15;
$month = "March";
$year = 2023;
?>
Udskriv datoen i formatet:
'Date: March 15, 2023'