My PHP String
";
// (3) The increment operator
$countNew = 1;
$countNew++; // 2 → Same as $countNew = $countNew + 1;
echo $countNew; // 2
$first_name = 'Bob';
$last_name = 'Roberts';
$name1 = 'Name: ' . $first_name; // Name: Bob
echo $name1;
$name2 = $first_name . ' ' . $last_name; // Bob Roberts
echo $name2;
echo "
";
// To join a number to a string
$price = 19.99;
$price_string = 'Price: ' . $price; // Price: 19.99
echo $price_string ;
echo "
";
?>
";
echo "I love W3Schools.com!"; // A string display
echo "
";
echo "I love ". $txt2 . "!"; // using (.) operator to combine strings and a variable.
echo "
";
$x = 5;
$y = 4;
echo $x + $y; // 9 is the result.
?>
Go to Next Page
Go to Next Page
Go to Next Page
Go to Next Page
Go to Next Page
Go to Next Page