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:
@ -5,13 +5,14 @@
|
||||
<li><a href="<?= page_path('basics') ?>">Basics</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('strings') ?>">Strings</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('conditionals') ?>">Conditionals</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('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-visibility') ?>">Classes: Visibility</a></li>
|
||||
<li><a href="<?= page_path('classes-constructor') ?>">Classes: Constructor</a></li>
|
||||
|
23
code/strings.php
Normal file
23
code/strings.php
Normal 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;
|
@ -27,12 +27,18 @@ return [
|
||||
'title' => 'Arithmetic',
|
||||
'subtitle' => 'Doing math like a pro',
|
||||
'previous' => 'variables',
|
||||
'next' => 'strings',
|
||||
]),
|
||||
Page::create('strings', null, 'strings.php', [
|
||||
'title' => 'Strings',
|
||||
'subtitle' => 'Working with text',
|
||||
'previous' => 'arithmetic',
|
||||
'next' => 'comparisons',
|
||||
]),
|
||||
Page::create('comparisons', null, 'comparisons.php', [
|
||||
'title' => 'Comparisons',
|
||||
'subtitle' => 'Equality checking',
|
||||
'previous' => 'arithmetic',
|
||||
'previous' => 'strings',
|
||||
'next' => 'boolean-logic',
|
||||
]),
|
||||
Page::create('boolean-logic', null, 'boolean-logic.php', [
|
||||
|
Reference in New Issue
Block a user