1
0
mirror of https://github.com/restoreddev/phpapprentice.git synced 2025-07-10 10:06:20 +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

View File

@ -5,13 +5,14 @@
<li><a href="<?= page_path('basics') ?>">Basics</a></li> <li><a href="<?= page_path('basics') ?>">Basics</a></li>
<li><a href="<?= page_path('variables') ?>">Variables</a></li> <li><a href="<?= page_path('variables') ?>">Variables</a></li>
<li><a href="<?= page_path('arithmetic') ?>">Arithmetic</a></li> <li><a href="<?= page_path('arithmetic') ?>">Arithmetic</a></li>
<li><a href="<?= page_path('strings') ?>">Strings</a></li>
<li><a href="<?= page_path('comparisons') ?>">Comparisons</a></li> <li><a href="<?= page_path('comparisons') ?>">Comparisons</a></li>
<li><a href="<?= page_path('boolean-logic') ?>">Boolean Logic</a></li> <li><a href="<?= page_path('boolean-logic') ?>">Boolean Logic</a></li>
<li><a href="<?= page_path('conditionals') ?>">Conditionals</a></li> <li><a href="<?= page_path('conditionals') ?>">Conditionals</a></li>
<li><a href="<?= page_path('loops') ?>">Loops</a></li> <li><a href="<?= page_path('loops') ?>">Loops</a></li>
<li><a href="<?= page_path('arrays') ?>">Arrays</a></li> <li><a href="<?= page_path('arrays') ?>">Arrays</a></li>
<li><a href="<?= page_path('functions') ?>">Functions</a></li> <li><a href="<?= page_path('functions') ?>">Functions</a></li>
<li><a href="<?= page_path('classes') ?>">Classes: Introduction</a></li> <li><a href="<?= page_path('classes') ?>">Classes</a></li>
<li><a href="<?= page_path('classes-inheritance') ?>">Classes: Inheritance</a></li> <li><a href="<?= page_path('classes-inheritance') ?>">Classes: Inheritance</a></li>
<li><a href="<?= page_path('classes-visibility') ?>">Classes: Visibility</a></li> <li><a href="<?= page_path('classes-visibility') ?>">Classes: Visibility</a></li>
<li><a href="<?= page_path('classes-constructor') ?>">Classes: Constructor</a></li> <li><a href="<?= page_path('classes-constructor') ?>">Classes: Constructor</a></li>

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;

View File

@ -27,12 +27,18 @@ return [
'title' => 'Arithmetic', 'title' => 'Arithmetic',
'subtitle' => 'Doing math like a pro', 'subtitle' => 'Doing math like a pro',
'previous' => 'variables', 'previous' => 'variables',
'next' => 'strings',
]),
Page::create('strings', null, 'strings.php', [
'title' => 'Strings',
'subtitle' => 'Working with text',
'previous' => 'arithmetic',
'next' => 'comparisons', 'next' => 'comparisons',
]), ]),
Page::create('comparisons', null, 'comparisons.php', [ Page::create('comparisons', null, 'comparisons.php', [
'title' => 'Comparisons', 'title' => 'Comparisons',
'subtitle' => 'Equality checking', 'subtitle' => 'Equality checking',
'previous' => 'arithmetic', 'previous' => 'strings',
'next' => 'boolean-logic', 'next' => 'boolean-logic',
]), ]),
Page::create('boolean-logic', null, 'boolean-logic.php', [ Page::create('boolean-logic', null, 'boolean-logic.php', [