1
0
mirror of https://github.com/restoreddev/phpapprentice.git synced 2025-07-13 11:36:19 +02:00

Added strings page

This commit is contained in:
Andrew Davis
2018-09-05 20:57:50 -05:00
parent b1fb56c1c2
commit 9cf9559aea
3 changed files with 32 additions and 2 deletions

23
code/strings.php Normal file
View File

@ -0,0 +1,23 @@
<?php
// As seen in the first chapter, a string is a group of characters created by
// surrounding text in single or double quotes.
$firstname = 'Joey';
$lastname = "Johnson";
// A double quoted string can interpret special characters starting
// with a back slash to create formatting. The \n creates a newline
// between the names and after them.
echo "Jacob\nJones\n";
// Double quoted strings can also embed variables in the text. This code
// outputs "Cindy Smith".
$firstname = 'Cindy';
echo "$firstname Smith\n";
// Another feature of strings is the ability to combine them together.
// To combine two strings, use the period character in between them.
$firstname = 'Jenny';
$lastname = 'Madison';
$fullname = $firstname . $lastname;
echo $fullname;