100% found this document useful (1 vote)
9 views

PHP 8 Basics: For Programming and Web Development Gunnard Engebreth download

The document promotes the book 'PHP 8 Basics: For Programming and Web Development' by Gunnard Engebreth and Satej Kumar Sahu, which aims to help beginners learn PHP 8 and its application in web development. It covers fundamental concepts, installation, and configuration of PHP, as well as integration with MySQL and popular frameworks like Laravel and Symfony. The book includes practical examples and is available for download at ebookmass.com.

Uploaded by

hastirdujan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
9 views

PHP 8 Basics: For Programming and Web Development Gunnard Engebreth download

The document promotes the book 'PHP 8 Basics: For Programming and Web Development' by Gunnard Engebreth and Satej Kumar Sahu, which aims to help beginners learn PHP 8 and its application in web development. It covers fundamental concepts, installation, and configuration of PHP, as well as integration with MySQL and popular frameworks like Laravel and Symfony. The book includes practical examples and is available for download at ebookmass.com.

Uploaded by

hastirdujan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 74

Download the full version and explore a variety of ebooks

or textbooks at https://ebookmass.com

PHP 8 Basics: For Programming and Web Development


Gunnard Engebreth

_____ Follow the link below to get your download now _____

https://ebookmass.com/product/php-8-basics-for-programming-
and-web-development-gunnard-engebreth/

Access ebookmass.com now to download high-quality


ebooks or textbooks
We have selected some products that you may be interested in
Click the link to download now or visit ebookmass.com
for more options!.

PHP 8 Basics: For Programming and Web Development 1st


Edition Gunnard Engebreth

https://ebookmass.com/product/php-8-basics-for-programming-and-web-
development-1st-edition-gunnard-engebreth/

PHP: 3 books in 1 : PHP Basics for Beginners + PHP


security and session management + Advanced PHP functions
Andy Vickler
https://ebookmass.com/product/php-3-books-in-1-php-basics-for-
beginners-php-security-and-session-management-advanced-php-functions-
andy-vickler/

An Introduction to PHP: Learn PHP 8 to Create Dynamic


Websites 1st Edition Mark Simon

https://ebookmass.com/product/an-introduction-to-php-learn-php-8-to-
create-dynamic-websites-1st-edition-mark-simon/

An Introduction to PHP: Learn PHP 8 to Create Dynamic


Websites Mark Simon

https://ebookmass.com/product/an-introduction-to-php-learn-php-8-to-
create-dynamic-websites-mark-simon/
JavaScript for Web Developers: Understanding the Basics
1st Edition Mark Simon

https://ebookmass.com/product/javascript-for-web-developers-
understanding-the-basics-1st-edition-mark-simon/

How JavaScript Works: Master the Basics of JavaScript and


Modern Web App Development 1st Edition Jonathon Simpson

https://ebookmass.com/product/how-javascript-works-master-the-basics-
of-javascript-and-modern-web-app-development-1st-edition-jonathon-
simpson-2/

How JavaScript Works: Master the Basics of JavaScript and


Modern Web App Development 1st Edition Jonathon Simpson

https://ebookmass.com/product/how-javascript-works-master-the-basics-
of-javascript-and-modern-web-app-development-1st-edition-jonathon-
simpson/

Kotlin for Web Development and Kotlin Collections: A


Beginner's Odyssey in Web Development 2 Books in 1 Jp
Parker
https://ebookmass.com/product/kotlin-for-web-development-and-kotlin-
collections-a-beginners-odyssey-in-web-development-2-books-in-1-jp-
parker/

Introducing ReScript: Functional Programming for Web


Applications 1st Edition Danny Yang

https://ebookmass.com/product/introducing-rescript-functional-
programming-for-web-applications-1st-edition-danny-yang/
Gunnard Engebreth and Satej Kumar Sahu

PHP 8 Basics
For Programming and Web Development
Gunnard Engebreth
Madison, WI, USA

Satej Kumar Sahu


Bangalore, India

ISBN 978-1-4842-8081-2 e-ISBN 978-1-4842-8082-9


https://doi.org/10.1007/978-1-4842-8082-9

© Gunnard Engebreth, Satej Kumar Sahu 2023

This work is subject to copyright. All rights are solely and exclusively
licensed by the Publisher, whether the whole or part of the material is
concerned, specifically the rights of translation, reprinting, reuse of
illustrations, recitation, broadcasting, reproduction on microfilms or in
any other physical way, and transmission or information storage and
retrieval, electronic adaptation, computer software, or by similar or
dissimilar methodology now known or hereafter developed.

The use of general descriptive names, registered names, trademarks,


service marks, etc. in this publication does not imply, even in the
absence of a specific statement, that such names are exempt from the
relevant protective laws and regulations and therefore free for general
use.

The publisher, the authors, and the editors are safe to assume that the
advice and information in this book are believed to be true and accurate
at the date of publication. Neither the publisher nor the authors or the
editors give a warranty, expressed or implied, with respect to the
material contained herein or for any errors or omissions that may have
been made. The publisher remains neutral with regard to jurisdictional
claims in published maps and institutional affiliations.
This Apress imprint is published by the registered company APress
Media, LLC, part of Springer Nature.
The registered company address is: 1 New York Plaza, New York, NY
10004, U.S.A.
This book is dedicated to my wife Erica and to my boys Trip and
Wyatt.Also, you the reader. Thank you!
Jesus looked at them and said, “With man this is impossible, but with God
all things are possible.”
—Matthew 19:26!
Introduction
Developing web pages and applications is still, after many years, one of
the most fascinating endeavors for developers. The idea of taking a
simple idea and developing it, seeing it coming alive and imagining the
experience the user will have is something very magical.
The experience of programming as web developer should, of course,
also be easy, user-friendly, and flexible—all characteristics of the
programming language this book is all about: PHP version 8.
The first version of PHP was created by Rasmus Lerdorf in 1994 and
he mainly used it on his home page to keep track of who was looking at
his online resume. In 1995, the first public version was published as the
Personal Home Page Tools.
In the beginning, PHP was just a simple programming language with
a very easy parser engine that only understood a small number of
utilities and macros.
PHP usage grown. In 1996, about 15,000 web sites were developed
with PHP; by 1997, it was up to 50,000. In 1999, about 1 million web
sites were developed with PHP. At the time of writing, 78 million of web
sites have been developed with PHP to give you a perspective of how
popular this programming language has become. Why?
Simple. Because after many years it is still easy to use, user-friendly,
and clearly organized. This helps would-be programmers easily
understand and run PHP commands and functions.
We want to help PHP beginners and would-be developers explore
the new features added to this version 8 and see how easy, flexible, and
powerful it can be to develop new web sites and applications.
You will find all the basic information about how to install and
configure PHP version 8.
All basic PHP concepts like data types, functions, regular
expressions, form handling and verification, sessions, cookies, and
filters are introduced and demonstrated with many examples.
We also introduce the basic information of object-oriented
programming and its classes and objects.
This book also provides some simple examples about how to use
PHP version 8 with one of the most powerful and used databases for
developers, MySQL. You learn how to develop an entire web application
using PHP version 8 and MySQL.
You also learn about PHP frameworks and why they are so
important to use. This book focuses on just two of the many PHP
frameworks available, Symfony and Laravel, and the development of
web applications following the model–view–controller architectural
pattern.
Who This Book Is For
The book assumes you have some web development and DB handling
knowledge. The book is written mainly for the beginning web
developer who wants to learn how to use PHP version 8 and how it can
be used with MySQL and PHP frameworks like laravel and Symfony. It
also assumes you have some knowledge of programing language
frameworks and how and when you should use them with PHP.

Prerequisites
The examples in this book were built with PHP version 8. We also used
MySQL for Ubuntu Linux version 22.04 DEB Bundle. As a testing tool,
we used the latest Postman API client version available on the Web, but
you are free to use any testing tool you feel comfortable with. Finally,
we introduced and utilized two different PHP Frameworks named
Laravel and Symfony, which will be needed for the examples of this
book.

Downloading the Code


The source code for the examples in this book is available at
www.github.com/apress/php8-basics.
Any source code or other supplementary material referenced by the
author in this book is available to readers on GitHub
(https://github.com/Apress). For more detailed information, please
visit www.apress.com/source-code.
Acknowledgments
I would like to dedicate this book to my parents for always believing in
and having patience with me while I pursued my interest in technology,
and gave me the freedom to explore and try different things. Also,
thanks to my sister Lipsa for always being beside me whenever I
needed her. I would like to thank all my teachers for being with me
during my journey, Runish for the foundational mentoring support at
the start of my career, Mindfire Solutions for my first career
opportunity, and to all with whom I had an opportunity to interact and
learn from. Last but not least I would like to thank Mark for the
awesome opportunity to write my first book and the wonderful team at
Apress for all their support without whom this book would not have
been possible.
Table of Contents
Chapter 1:​Getting Started
Why Use PHP?​
Using PHP
Why PHP, Ngnix, and MySQL?​
Installing Docker
Windows
Mac OS
Linux
Installing Docker-Compose
The Development Environment
Summary
Chapter 2:​PHP Fundamentals
Variables
Using Errors As Tools
Objects
Verbs:​GET and POST
Summary
Chapter 3:​Functions, Classes, and Traits
OOP
Reviewing Class Definitions
Class Visibility
A Closer Look at Class Inheritance
Polymorphism and Abstract Classes
Constants
Constructs
Traits
Namespaces
Summary
Chapter 4:​Data and Data Types
PHP Data Types
PHP Data Types:​Scalar Types
Boolean
Integer
Float
String
PHP String Functions
substr( )
strlen( )
str_​replace()
trim( )
strpos( )
strtolower( )
strtoupper( )
is_​string( )
strstr( )
PHP Data Types:​Compound Types
Array
Object
PHP Data Types:​Special Types
NULL
resource
Summary
Chapter 5:​Form Data
PHP POST Form
PHP GET Form
Summary
Chapter 6:​Arrays
PHP Indexed and Associative Arrays
PHP Multidimensional​Arrays
PHP Array Functions
array_​change_​key_​case
array_​chunk
array_​column
array_​combine
array_​count_​values
array_​diff_​assoc
array_​diff_​key
array_​diff_​uassoc
array_​diff_​ukey
array_​diff
array_​fill_​keys
array_​fill
array_​filter
array_​flip
array_​intersect_​assoc
array_​intersect_​key
array_​intersect_​uassoc
array_​intersect_​ukey
array_​intersect
array_​is_​list
array_​key_​exists
array_​key_​first
array_​key_​last
array_​keys
array_​map
array_​merge_​recursive
array_​merge
array_​multisort
array_​pad
array_​pop
array_​product
array_​push
array_​rand
array_​reduce
array_​replace_​recursive
array_​replace
array_​reverse
array_​search
array_​shift
array_​slice
array_​splice
array_​sum
array_​udiff_​assoc
array_​udiff_​uassoc
array_​udiff
array_​uintersect_​assoc
array_​uintersect_​uassoc
array_​uintersect
array_​unique
array_​unshift
array_​values
array_​walk_​recursive
array_​walk
array
arsort
assort
compact
count
current
each
end
extract
in_​array
key_​exists
key
krsort
ksort
list
natcasesort
natsort
next
prev
range
reset
rsort
shuffle
sizeof
sort
uasort
uksort
usort
Summary
Chapter 7:​Sessions and Cookies
PHP Sessions
PHP Cookies
Summary
Chapter 8:​Objects
Output
Summary
Chapter 9:​PHP Exceptions, Validation, and Regular Expressions
PHP Exceptions
PHP Form Validation
PHP Regular Expressions
Regular Expressions Modifiers
Regular Expression Metacharacters
Regular Expression Square Brackets
Regular Expression Quantifiers
Regular Expression Functions
Summary
Chapter 10:​PHP and MySQL Working Together
PHP Communication with MySQL
PHP Communication with the MySQLi Method
PHP Communication with the PDO Method
MySQLi Advantages
PDO Advantages
PHP Connection to a Database
Summary
Chapter 11:​Data
Planning for a New Database
Creation of a New Database
Summary
Chapter 12:​Website with a DB
Summary
Chapter 13:​Introduction to Frameworks
Introduction to Frameworks
Pros and Cons of Frameworks
Pros of Using Frameworks
Cons of Using Frameworks
MVC Pattern
Different Layers of a Framework
Different Types of Frameworks
Role of Composer
Introduction of PHP Standard Recommendation (PSR)
PHP Frameworks
Choosing a Framework
Summary
Chapter 14:​Introduction to Laravel
Introduction to Laravel
Installing Laravel
Database Setup and Configuration
Database Migrations
Controller Route
Registration View Form
Storing User Data in a Database
Summary
Chapter 15:​Introduction to Symfony
Introduction to Symfony
Installing Symfony
Creating a Symfony Application
Summary
Chapter 16:​A Basic Symfony Application
Creating a New Symfony Project
Database Setup and Configuration
Controller Route
Registration View Form
Storing User Data in a Database
Summary
Index
About the Authors
Gunnard Engebreth
began coding at the age of 11 through a
“Learning BASIC” book given to him by
his father. Technology was changing fast,
and Gunnard rode the wave from 1200
to 56k baud modems. Logging into BBSs,
Prodigy, CompuServe, Delphi, and IRC, he
could see the world changing and he
wanted to be a part of it. He soon got
involved in the ANSI/demo scene,
making several application generators
for many groups in the 1990s. Visual
Basic was his next language of choice,
allowing him to develop “tools” for
online systems such as AOL. This
introduced many aspects of
development, security, and user interfaces while they were still in their
infancy. Once the World Wide Web arrived via Mindspring in Atlanta,
Georgia, Gunnard quickly joined in the race for the Web. Learning
HTML, PERL, and Linux (Slackware at the time), he began to build his
skill set, which led to a full-time systems administrator position at the
age of 20 (2000) at Activegrams/Silverpop. Gunnard has moved around
the IT industry from SAN/NAS storage at IBM to custom WordPress
sites for marketing companies, but one thing has stayed the same: his
passion for learning and problem solving. Gunnard also DJs drum and
bass as Section31, plays drums, and bakes bread
(www.gunnard.org).

Satej Kumar Sahu


works in the role of Senior Software Data Architect at Boeing. He is
passionate about technology, people, and nature. He believes that
through technology and conscientious decision making, each of us has
the power to make this world a better place. In his free time, he can be
found reading books, playing basketball,
and having fun with friends and family.
About the Contributor
Massimo Nardone
has more than 26 years of experience in
security, web/mobile development, and
cloud and IT architecture. His true IT
passions are security and Android. He
has been programming and teaching
how to program with Android, Perl, PHP,
Java, VB, Python, C/C++, and MySQL for
more than 25 years. He holds a Master of
Science degree in Computing Science
from the University of Salerno, Italy. He
has worked as a Chief Information
Security Office (CISO), software engineer,
chief security architect, security
executive, OT/IoT/IIoT Security Leader,
and architect for many years.
© Gunnard Engebreth, Satej Kumar Sahu 2023
G. Engebreth, S. K. Sahu, PHP 8 Basics
https://doi.org/10.1007/978-1-4842-8082-9_1

1. Getting Started
Gunnard Engebreth1 and Satej Kumar Sahu2

(1) Madison, WI, USA


(2) Bangalore, India

PHP is the de facto programming language used to serve billions (“BILL” not “MILL”) a month.
PHP has grown from a hodge-podge collection of scripts that could be used to stitch together
a functional website into the backbone of several billion-dollar companies influencing how
industry works across the globe. Yes, there are other languages out there that do many things,
but you are not reading this book to understand them! You chose to step into the world of
PHP and join the network of developers who focus on solutions, community, and the
advancement of PHP. This chapter of the book will cover the why, when, and how of using the
PHP programming language. It will also introduce some programming development
environments and describe how to install Docker, which is an open platform for developing,
shipping, and running applications.

Why Use PHP?


FACT: PHP runs the Web. This is a bold statement but just look at these numbers:
Facebook: 25.7 billion monthly estimated visits
Wikipedia: 15 billion monthly estimated visits
Yahoo: 4.8 billion monthly estimated visits
Flickr: 65.44 million monthly estimated visits
Tumblr: 328.9 million monthly estimated visits
Any one of those sites above pull impressive numbers, but when combined, they are
pretty hefty statistics. Even if you have a loyalty to another programming language, you can’t
deny the use of PHP as a workhorse in these sites. While we can see that large corporations
have come to trust the language, what about average users like you and me? Over 39.5% of all
websites on the Internet are run on WordPress. Let that sink in for a minute. Almost 40% of
all websites are served up on a CMS (open source, no less) that is developed in PHP.
PHP is exploding yearly in terms of demand. A quick check on any job search website will
give you thousands of results.
PHP is continuously growing, with scheduled releases and a thriving community of
developers maintaining technological relevance.
PHP is the most exciting AND the most practical programming language you can get
started with today.
Admittedly, we may have our biases.
Using PHP
PHP is mainly used by developers in two ways. One method is to organize and deliver data
from a data source (i.e., a MySQL database) to a webpage. Think of Facebook or Twitter. The
content that you see on these sites is stored somewhere in a database and needs to be
retrieved and then parsed or organized, ultimately leading to a front-end display to the user.
Your cousin’s baby pictures with 40 likes must be gathered, the likes must be collected and
names attributed to them, and then they are ready to pop up on your timeline. Depending on
the infrastructure, this data can be stored in one location or multiple places, tied together
with unique identifiers. We may be getting ahead of ourselves here, but we are trying to
convey the fact that the information you see on webpages is cultivated by PHP from
information stored in databases. PHP is the toolbox you will use to build these powerful
applications.
We mentioned that there are two main ways to use PHP. The other way is on the command
line. There are usually several scripting languages on a server that can be used to perform all
sorts of tasks. Bash, Python, and Perl come to mind, but PHP can be used in the same way. If
you have not already, go to the GitHub repo linked from this book’s apress.com product
page and look at the Chapter 1 link. From here, you will set up the development environment
in order to look at and run these PHP scripts.
Let’s get the development environment spun up so you can see PHP in action.
PHP is a server-side scripting language and therefore needs a server with the appropriate
settings and resources to run. While PHP comes natively installed on many operating systems,
it can be installed or upgraded on its own. Examples of other server-side languages are
Python, Ruby, and Perl. The opposite of this is client-side languages. They are processed in the
browser and are based on JavaScript. Examples of client-side languages are Vue.js, jQuery, and
Node.js.

Why PHP, Ngnix, and MySQL?


Let us introduce you to your new best friends, at least in terms of your daily exposure to
them. As a developer, you will need to work with each of these new friends intimately. PHP (as
we have discussed) is the language in which we will be writing our scripts. Nginx is the web
server, which allows for web pages to be served when a user accesses specific URLs on a
server. When you go to gunnard.org, for example, the webserver at the hosting site looks at
the URL (www.gunnard.org) and checks to see if there are any associated www settings (in
Nginx) for this website. If there are, the software (Nginx) looks for the document root setting
and directs the user to that location. Once there, the first thing the server will look at, unless
otherwise specified, is an index.xhtml or index.php page. The index.xhtml/php
paradigm is fairly standard across the board and serves as a failsafe to protect directories
from being viewed across the Web. For example, if you have an assets/ directory with
private information that is publicly accessible, say gunnard.org/assets, but there is no
index.xhtml, this will be viewable to anyone, and they will see a list of files in that
directory. If a blank index.xhtml is placed there, the file will be shown instead. Within
Nginx you can set the priority and order in which Nginx looks for these default files. When
using PHP, it is necessary to specify that Nginx looks for index.php over index.xhtml, for
example.
In order to use your development environment, you need a tool called Docker. Docker
provides your computer (the host machine) with the ability to masquerade as a web server, in
your example, without creating a virtual machine separate from your host environment. This
might sound like the exact thing you WANT to do, which it is, but Docker goes about it in a
slightly different way that is more robust, easier to manage, and less invasive than your
typical virtual machine. Think of Docker as software that allows for a container to dress up
like a specific type of computer or server. This container is separate from your host system
but also uses the resources (directories, CPU, memory) of your host without actually changing
or creating a new machine. The inner workings of Docker vs. virtual machines is outside of
the scope of this book and frankly could take an entire book to explain it much better than we
just did. The bottom line is that with Docker, we control and can use the beneficial parts of a
web server without having to create, install, and maintain a real or virtual server. Plus, as of
printing, this is what 99% of development shops use; this is very industry standard.

Installing Docker
Let’s get Docker installed on your operating system of choice. Here’s how to do it.

Windows
Go to https://docs.docker.com/docker-for-windows/install/ and click the
“Docker Desktop for Windows” button to download Docker, as shown in Figure 1-1.

Figure 1-1 The Docker Desktop for Windows download button

1. Double-click Docker Desktop Installer.exe to run the installer.

2. When prompted, ensure the Enable Hyper-V Windows Features. If you have previously
configured WSL and are comfortable with it, then make sure the “Install required
Windows components for WSL 2” option is selected on the Configuration page.

3. Follow the instructions in the installation wizard to authorize the installer and proceed
with the install.

4. When the installation is successful, click Close to complete the installation process.

5. If your admin account is different to your user account, you must add the user to the
docker-users group. Run Computer Management as an administrator and navigate to
Local Users and Groups ➤ Groups ➤ docker-users. Right-click to add the user to the
group. Log out and log back in for the changes to take effect.
Docker Desktop does not start automatically after installation. To start Docker Desktop,
search for Docker, and select Docker Desktop in the search results. When the whale icon in
the status bar stays steady, Docker Desktop is up, running, and accessible from any terminal
window.

Mac OS
Go to https://docs.docker.com/docker-for-mac/install/, shown in Figure 1-
2.

Figure 1-2 Download options for Docker for Mac

Double-click Docker.dmg to open the installer and then drag the Docker icon to the
Applications folder, as shown in Figure 1-3.

Figure 1-3 Moving the Docker application to the Applications folder

Double-click Docker.app in the Applications folder to start Docker. (In Figure 1-4,
the Applications folder is in grid view mode.)
Figure 1-4 Docker Applications folder
The Docker menu in the top status bar indicates that Docker Desktop is running and
accessible from a terminal.

Linux
Go to https://docs.docker.com/engine/install/. Here you will find links to
instructions on how to install Docker on several popular Linux distributions. If you are using
Debian/Ubuntu, you can follow these instructions
(https://docs.docker.com/engine/install/ubuntu/):
1) Ensure that any older installation is removed from the system.

<code>
sudo apt-get remove docker docker-engine docker.io containerd
runc
</code>

2) Update the apt package index and install packages to allow apt to use a repository over
HTTPS.

<code>
sudo apt-get update
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg \
lsb-release
</code>

3) Add Docker’s official GPG key.

<code>
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg
--dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
</code>

4) Use the following command to set up the stable repository. To add the nightly or test
repository, add the word nightly or test (or both) after the word stable.

<code>
echo \
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-
keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee
/etc/apt/sources.list.d/docker.list > /dev/null
</code>

5) Update the apt package index and install the latest version of Docker Engine and
container.

<code>
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
</code>

If you have any difficulties or need to install a specific version of Docker for your system,
please visit https://docs.docker.com/engine/install/ where they cover many
more options and configurations than is possible in the scope of this section.
Once Docker is installed, you will need to install docker-compose. Compose is a tool for
defining and running multi-container Docker applications. Compose allows you to define an
application within the confines of a YAML (Yet Another Markup Language) file. This allows
you to spin up all of the defined services for your Docker container with a single command.
This is often used within development teams to ensure version control and maintain use of
third-party applications. Other features of Compose are
Multiple isolated environments on a single host
Preserving volume data when containers are created
Only recreating containers that have changed
Variables and moving a composition between environments
More on these features can be found at
https://docs.docker.com/compose/#features.

Installing Docker-Compose
Mac and Windows users that have installed Docker Desktop can skip the installation step
because Compose is included with the installed package.
1) For Linux users, run this command to download the current stable release of Docker
Compose:
<code>
sudo curl -L
"https://github.com/docker/compose/releases/download/1.29.1/docker-
compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
</code>

2) Apply executable permissions to the binary.

<code>
sudo chmod +x /usr/local/bin/docker-compose
</code>

Note If the command docker-compose fails after installation, check your path. You can
also create a symbolic link to /usr/bin or any other directory in your path.

For example,

<code>
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
</code>

Optionally, install command completion for the bash and zsh shells.
Test the installation.

<code>
$ docker-compose --version
</code>

The Development Environment


Now that you have Docker installed and ready to go, you need the YAML files for your project
to set up your development environment. Go to https://github.com/apress/php8-
basics and click the Download ZIP button, shown in Figure 1-5.
Figure 1-5 yaml files for your project
Once you have the ZIP file downloaded, unzip it in a directory of your choosing. We used
~/ (my users home directory) ~/coding. Once unzipped, your directory structure
should look something like Figure 1-6.

Figure 1-6 Unzipped project folder

Inside this directory will be all the information needed for Docker to start the
development environment.
Go ahead and run

<code>
docker-compose up
</code>

and watch Docker spin up (Figure 1-7).

Figure 1-7 Running the docker-compose command


Next, point your browser to

<code>
http://localhost:8000
</code>

and you should see the table of contents page for this book and verification that the
database has connected successfully. Go to the command prompt and type

<code>
docker ps
</code>

This command shows you any containers that Docker has or is currently using. Here you
can see the mysql, nginx, and beginning php containers. One last thing to verify is that you can
run PHP from within the PHP container. From the command line, type

<code>
docker exe -ti php-app bash
</code>

This connects you, much like ssh, to the container itself. From here, go into the Chapter1
directory.

<code>
cd Chapter1
</code>

Type

<code>
php first_script.php
</code>

You should see this output:

<code>
Output here
</code>

Summary
In this chapter, you learned in general the why, what, and how of using the PHP programming
language in the development world. We introduced why you want to use PHP, Nginx, and
MySQL and their benefits. As next steps, you learned how to install the Docker tool, which is
an open platform for developing, shipping, and running applications. Finally, you saw why you
needed the YAML files for your project to set up your development environment.
In the next chapter, we will explain how programming languages use variables to store
and manipulate data and to build useful tools in PHP.
© Gunnard Engebreth, Satej Kumar Sahu 2023
G. Engebreth, S. K. Sahu, PHP 8 Basics
https://doi.org/10.1007/978-1-4842-8082-9_2

2. PHP Fundamentals
Gunnard Engebreth1 and Satej Kumar Sahu2

(1) Madison, WI, USA


(2) Bangalore, India

In order to build useful tools in PHP, you need to know how to


manipulate data. Programming languages use variables to store and
manipulate data.
In this chapter, you will learn how programming languages use
variables to store and manipulate data and to build useful tools in PHP.
Additionally, you’ll explore the following topics:
Using errors as tools
Objects
Verbs: GET and POST

Variables
PHP has a few rules when it comes to variables:
A variable must start with the $ sign, followed by the name of the
variable.
A variable name must start with a letter or the underscore character.
A variable name cannot start with a number.
A variable name can only contain alpha-numeric characters and
underscores (A-z, 0-9, and _ ).
Variable names are case-sensitive ($pants and $PANTS are two
different variables).
Unlike other programming languages, PHP does not have a specific
command for declaring variables. You must pay attention to where and
how variables are declared and used.
Let's write some code and see how the browser handles it. Go into
your beginning-php8-and-mysql directory and under chapter
2, create a file called newtest.php. Inside of this file, write

<code>
<p>this is normal text</p>
<?php
echo '<p>This is created by php';
?>
<p>this is normal text again</p>
</code>

The code above shows three lines. The first is normal HTML, the
second is running PHP code, rendering HTML. The third is more HTML
but after/outside the PHP code snippet. You can go between PHP and
HTML as many times as you like within a .php file. This can get messy,
so you want to limit this to very clean and precise code elements. Now
create a file called vartest.php and open it up. Type this code into
the file and save it:

<code>
<?php
echo "<p>variable test</p>";
$color = "blue";
$item = "pants";
echo "Today I am using $item which happen to be
the color $color";
</code>

Navigate to localhost:8000/chapter2/vartest.php and


look at the results (Figure 2-1).
Figure 2-1 URL result web page
Ok, let's catch up on what you are doing here. First, you are
declaring the PHP script with

<code>
<?php
</code>

The next line you use echo. This is a PHP command that makes up
one of the most basic ways to display text from PHP to the browser. It
does one thing: sends output to the browser or command prompt.
Notice that after echo, you use the double quote (“) as the delimiter to
separate this portion of text and begin the line of text you wish to
output to the screen. When you are done with the text, you end it with
another double quote. The double quote is the delimiter that marks the
beginning and end of a line of text you want to use. As humans, we can
easily determine text or a sentence that is written down or on a screen.
Computers need special markings, delimiters in this case, to determine
where the text boundaries are. This is true for the echo command or
for setting a variable, as in the next line. $color is the name of a
variable you want to use and "blue" is the value you are setting it to.
In this particular case, $color is a variable of type string. A string is
any text that you want to use that will not be used to compute, say, a
mathematical value. Once you have the value of "blue" set in $color,
you can use echo to display it on the page. You do this again with the
variable $item when you set its value to "pants". You will notice as
well that each line of code ends with a semicolon (;). In PHP, this is how
you tell the interpreter to stop reading the line and move on. You will
get an error any time you leave out the ending semicolon.
Speaking of errors, let’s go ahead and get comfortable with errors
and how they can be useful to us instead of annoyances.
Using Errors As Tools
In PHP, you do not always see the errors that occur. This is because
there are three different levels with configurations for how and where
to display them. Let’s go back into vartest.php and add these lines
to the top:

<?php
error_reporting( E_ALL );
ini_set( "display_errors", 1);

//this next line is an error


echo "these pretzels are making me thirsty;

echo "<p>variable test</p>";


$color = "blue";
$item = "pants";
echo "Today I am using $item which happen to be
the color $color";

Before you run this, let’s explain what you are doing.
error_reporting( E_ALL ); is telling PHP to display ALL
errors. Here is the full list of options available for error_reporting:

<?php

// Turn off all error reporting


error_reporting(0);

// Report simple running errors


error_reporting(E_ERROR | E_WARNING | E_PARSE);

// Reporting E_NOTICE can be good too (to report


uninitialized
// variables or catch variable name misspellings
...)
error_reporting(E_ERROR | E_WARNING | E_PARSE |
E_NOTICE);
// Report all errors except E_NOTICE
error_reporting(E_ALL & ~E_NOTICE);

// Report all PHP errors


error_reporting(E_ALL);

// Report all PHP errors


error_reporting(-1);

// Same as error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);
The next line of ini_set() is used in PHP to overwrite
configuration options that are set in the php.ini file. This is helpful
when you need to do one-off configurations or are on a server where
you do not have access to the ini file. The next line is the error line. Do
you see it? Go ahead and pull up the file in your browser and see what it
says.

<code>
Parse error: syntax error, unexpected token ">" in
/var/www/chapter2/vartest.php on line 8
</code>

Using this error, you can begin to hunt down the bug. This error is
saying that line 8 has an unexpected >. Take a look at line 8 of your
code:

<code>
echo "<p>variable test</p>";
</code>

This line looks perfectly fine to me. What PHP is telling us is that
you have done something, in this case set a delimiter for text, on the
line BEFORE line 8 and now the perfectly acceptable > on line 8 is
unexpected. You need to look at line 6 where you will find the closing
delimiter of “ missing at the end of your text. Go ahead and add “ to the
end of the line and refresh your page, which should now render with no
errors.
Now that you can create and assign variables, render text to the
screen, and trigger/understand errors that show up, let’s start building
some pages. This is the reason you picked up this book, right? Go back
to your Chapter2 directory and open the file main.php.

<code>
<?php
error_reporting( E_ALL );
ini_set( "display_errors",1);
$title = "Beginning PHP 8 & MySQL";
$content = "Here is the main content for this
page";

$html ="
<!doctype html>

<html lang='en'><?php

<head>
<meta charset='utf-8'>

<title>$title</title>
<meta name='description' content='Basic HTML5
Page'>
<meta name='author' content='Your name'>

<link rel='stylesheet' href='css/styles.css?


v=1.0'>

</head>

<body>
$content
</body>
</html>";
echo $html;
</code>
These are the basic elements needed for a HTML 5 webpage with
PHP included. You are declaring that you want errors to be turned on at
the top, as you have done before. The next lines set two variables, one
for the title and one for the content. The rest of the file sets the variable
$html to the entirety of HTML that you want displayed on the page.
Within this code you see the $title and $content variables placed
where you want to display them on the page. Go ahead and open your
browser to this page to see how it looks. This can get a little redundant
if you have many pages that follow the same look and feel presented
with the HTML. Therefore, you will use this page as a template that you
can call and just switch out the values you want displayed. Open up
main2.php in your editor.

<code>
<?php
//error_reporting( E_ALL );
//ini_set( "display_errors",1);
$title = "Beginning PHP 8 & MySQL";
$content = "Here is the main content for this
page";
$html =include_once "inc/template2.php";
</code>

Here you are introducing the include_once function. By calling


include_once, you tell PHP that you want to load a specific file into
this area. By separating out the design aspect (HTML) from the PHP,
you can view your code better and reuse the HTML elements in other
PHP files. Building on this example, let’s take it a step further and
include multiple PHP files in your template. In main2.php, change
template.php to template2.php and refresh the page.
In your case, you first include header.php, located within the
inc/ directory. When you use this method of including PHP snippets
around the HTML in your file, you are essentially creating a template.
This template (main.php), if used in another file, will still include a
header, contents, and footer. Let’s create a file called second.php by
copying the main.php file and naming it second.php.
Now that you have come to an understanding with your templates
on how to separate them and use them to your advantage, let’s take a
look at your variables. So far you have been using variables for trivial
content, colors, and item names. What if you want to store someone’s
name and address? It’s perfectly correct to do something like this:

<code>
$firstName = "gunnard";
$lastName = "engebreth";
</code>

This works fine until you want to start passing this information
around between functions in your program. Basically, envision passing
your friend a handful of Skittles vs. a bag of Skittles. Your friend still
gets the Skittles in the end, but one way is clean, optimized, and all
Skittles are guaranteed to reach your friend. This brings us to objects.

Objects
In PHP, an object is a specific set of data as defined in a class. In the
code example above, you would say that the information would belong
to a class of User. You would define that class as such:

<code>
<?php
class UserClass
/* User variables */
var $firstName;
var $LastName;

/* Member functions */
function setFirstName($firstName){
$this->firstName = $firstName;
}

function getFirstName(){
echo $this->firstName;
}

function setLastName($lastName){
$this->lastName = $lastName;
}

function getLastName(){
echo $this->lastName;
}
}
</code>

To create a new user you can call


<code>
$user = new UserClass();
$user->setFirstName('gunnard');
$user->setLastName('engebreth');
var_dump($user);
</code>
Let’s take a look at this code.
$user = new UserClass(); does exactly what it shows: the
variable $user is now going to have the configuration and format that
you described in the class UserClass. This also demonstrates the
importance of proper naming in PHP. With one look at this line of code,
you can have a high percentage of certainty that this variable $user is
most likely going to be associated with $UserClass somehow and
less likely to be associated with a class named $DumpTruckClass.
The next two lines call a method (function) you create within
UserClass. These specific types of methods, Get____ and Set___,
are known as helpers and also commonly referred to as the class
“getters” and “setters.” These methods simplify the task of setting
values within the object.
The last line is a PHP-specific function used heavily in debugging
code. var_dump() shows you exactly what is in a variable and what
type of variable you are analyzing. In your example, calling var_dump
shows all the information within the object. $user is the bag of Skittles
and $user->firstName is the individual Skittle.
Now, how do you use this all together? You need to specify the class
information in one file and include it in another file. Thankfully, you
already know how to do that. Let’s open up main3.php.

<code>
<?php
$title = "main3 php file";
require "UserClass.php";
$user = new UserClass;
$user->setFirstName = 'gunnard';
$user->setLastName = 'engebreth';
var_dump($user);
error_reporting( E_ALL );
ini_set( "display_errors",1);
$html =include_once "inc/template2.php";
</code>

You have already reviewed what the first two lines do, so set up and
set the variable $user as a part of the class UserClass. The next two
lines set the first name and last name. If you run this script on the
command line or browser, you can verify this through the
var_dump() function. Figure 2-2 shows what you should see.

Figure 2-2 Code result web page

This is a fundamental stage in development. You have created an


object, assigned values, and can display the information on the page.
Now you need to make it dynamic by adding user interaction via forms.
Forms are more than just what you use to comment on someone’s
picture on Facebook. Forms are the method by which a user can
interact with a program. The user can directly communicate with the
code and the database you have created. With this kind of access, great
detail must be put into validation and sanitization of input, which we
will get to later. For now, just get comfortable with getting and using
input. Let’s get technical about receiving data from the user.

Verbs: GET and POST


HTTP (Hyper Text Transfer Protocol) is what connects the Web that you
know today. This is the protocol or method of agreed-upon
communication that allows for servers, PHP, and users to talk to one
another. There are a lot of specifications within HTTP for everything
including error handling, expected standard document formats, and
request methods. These methods are defined in five verbs:
GET
The GET method requests a representation of the specified resource.
Requests using GET should only retrieve data.
POST
The POST method is used to submit an entity to the specified
resource, often causing a change in state or side effects on the server.
PUT
The PUT method replaces all current representations of the target
resource with the request payload.
DELETE
The DELETE method deletes the specified resource.
PATCH
The PATCH method is used to apply partial modifications to a
resource.
You will be focusing on GET and POST but rest assured, you will be
using the others as you build your REST API.
Point your browser to
http://localhost:8000/chapter2/main4.php?
pants=123. Notice in the URL you have main4.php?pants=123.
When the page loads, it should look like Figure 2-3.

Figure 2-3 URL result web page

At the top is var_dump() and you can see that the info you have in
the URL is now available to you in PHP as the variable $userVars.
This is available to you through the HTTP verb GET and in PHP you use
the global variable $_GET. GET specifically allows for the transfer of
data through the URL. You can send multiple values as well. Change the
URL to include

<code>
http://localhost:8000/chapter2/main4.php?
pants=123&dog=poodle&food=spaghetti
</code>

Refresh the page and you will now see that Pants, Dog, and
Food have values set to them. The other method of transmitting data
from the user to your code is using POST.
The POST verb behaves in nearly the same way but does not use the
URL, thereby keeping the data you are transmitting a bit more secure.
In order to see the POST functionality, open main5.php and take a
look.
<code>
<?php
$userVars = $_POST;
$title = "main5 php file";
require "UserClass.php";
$user = new UserClass;
$user->setFirstName = 'gunnard';
$user->setLastName = 'engebreth';
var_dump($userVars);
error_reporting( E_ALL );
ini_set( "display_errors",1);
$html =include_once "inc/template3.php";

</code>
The main things that changed in this code are that you are using the
PHP global $_POST instead of $_GET and you include
template3.php. Let’s look at the tempalte3.php file.

<code>
$content = include('contentPost.php');
</code>

Template3 calls in a specific content piece called


contentPost.php.

<code>
<form action="<?php echo
htmlspecialchars($_SERVER["PHP_SELF"]);?>"
method="post">
<input type="text" id="firstName" name="firstName"
/>
<input type="text" id="lastName" name="lastName"
/>
<input type="submit" name="submit">
</code>
Here you see the differences in that allow you to use $_POST. You
define a form and set the action to the file (main5.php) itself. This
code you see allows for the form to be used in multiple places by
dynamically finding the name of the file that houses the form and
putting it there. $_SERVER['PHP_SELF'] is the file currently calling
this script and htmlspecialchars is a PHP function that removes
HTML because it can be used for malicious or evil intent. The two lines
underneath declare the firstname and lastname boxes to collect the
users input. Finally, you have a Submit button that triggers the form to
be used by your code. Go ahead and fill it out and then look at the
resulting page (Figure 2-4).

Figure 2-4 Code result web page

You can see in your var_dump that the variables for first name and
last name came through, and if you look at your URL, you see that it is
clean and no variables are listed. In your examples, you used GET and
POST to submit data to your PHP. Technically, you could use GET to
submit this form as well, but you should really not do that. These two
methods, GET and POST, are (as listed above) part of a larger group of
verbs that are used currently in modern development in APIs. An
application programming interface (API) is a method of allowing access
for developers to interact with an application. Think about it this way:
stock tickers, tweet streams, an Instagram plugin for WordPress--these
all are individual pieces of software that connect to other things:
Stock ticker -> Bloomberg API
Tweet stream -> Twitter API
Instagram gallery -> Instagram API
Other documents randomly have
different content
tahansa saattoi syöksyä metsästä. Kun komppaniassa oli vähän
miehiä ja vartiopaikkoja paljon, täytyi siinä kitua kolme, neljä, jopa
muutaman kerran kuusikin tuntia perätysten, ja kun vihdoin pääsi
lähtemään kotiin, niin ei siihen enää tahtonut kyetä, niin oli vilusta
jäykkä. Muistan joskus ajatelleeni, etteivät meidän ylennetyt
miehemme sentään oikeastaan tunteneet, mitä oli olla tavallisena
sotilaana. Heidän ei tarvinnut luonnollisestikaan ottaa osaa työhön,
ei myöskään vartiointiin, he ainoastaan järjestelivät ja komentelivat.
Olivathan he tosin olleet Saksassa alusta alkaen, mutta niin oli moni
jääkärikin; kaiken lisäksi heillä oli paljoa parempi palkka. Eivät he
olleet kokeneet, mitä oli maata tuntikausia märkänä, jäätyvällä
suolla. — Mutta lienee ollut paljon, josta vuorostamme me emme
tietäneet.

Tätä etuvarustusta sanottiin Siperiaksi, koska sinne määrätty


vartio oli ikäänkuin karkoitettu kotoaan. Sen rakentaminen oli jo
kysynyt ihmisuhrejakin: kaksi poikaa ensimäisestä komppaniasta oli
kaatunut. Kun he aamulla olivat menneet määräpaikalleen
suojaamaan työskenteleviä pionieerejä, olivat ryssät, hiivittyään yöllä
väijyksiin, ilman muuta ampuneet heidät. Ja kummallista, kun pojat
aikoivat hyökätä näiden murhaajien niskaan, niin saksalainen
luutnantti, joka oli työtä johtamassa, kielsi heitä kiven kovaan, meni
itse kulmavarustuksen suojaan ja komensi kaikki valmiiksi
peräytymään, koska muka ryssät aikoivat hyökätä. Vasta kun
ryhmänjohtaja J. ensimäisestä komppaniasta saapui paikalle, kokosi
hän ympärilleen vapaa-ehtoisen joukon, ryntäsi metsään, ajoi ryssät
pakoon, saipa heistä kaksi ammutuksikin: toinen oli vääpeli
arvoltaan. [Katso Suomen Jääkärit ss. 167-170. Tekijän huom.]

Kahakka tuotti rautaristejä ja laskemassa ollut maineemme alkoi


jälleen kohota. Niinpä tehtiin useampiakin onnistuneita kaappauksia.
Oberzugführer G., joka meiltä oli siirretty kolmanteen komppaniaan,
tappoi vuorostaan ja ikäänkuin kostoksi venäläisen vartion. Hän otti
mukaansa pienen joukon, jonka varusti käsigranaateilla ja hiipi sitten
sen maahan kaivetun suojuksen lähettyville, jossa vahtimiesten
tiedettiin seisovan. Suojuksesta johti juoksuhauta ryssäin puolelle ja
tätä pakotietä tukkimaan lähetti johtaja käsigranaatti-miehet.
Päästyään sopivan matkan päähän alkoivat pojat syytää pommeja
hautaan ja samaan aikaan hyppäsi oberzugführer, mukanaan myötä
seurannut ryhmänjohtaja, kylmäverisesti suoraan suojukseen ja
ampui revolverillaan vahdit kuoliaaksi. Vangiksi-ottoon ei ollut aikaa;
voittosaaliina tuotiin vain yksi 55. siper. tarkka-ampujarykmentin
mies, olkalaput ja kiväärit.

Näihin aikoihin siirrettiin minut ensimäisestä joukkueesta toiseen


ja tuon siirron yhteydessä muistuu mieleeni omituinen ja sangen
onnellinen tapaus. Olin itse muokannut kämpän nurkkaan mukavan,
vaikka kapean vuoteen ja kun lähtijäisiä vietettiin, luovutin sen
Sedälle, joka sitä kummallisen hartaasti pyysi. Tuli sitten
päivällisaika, pari tuntia muuttoni jälkeen. Pojat olivat jo syöneet ja
makailivat kaikessa rauhassa, Setä uudella vuoteellaan, kun yhtäkkiä
lentää hurahti granaatti sisään, puhkaisi Sedän entisen päänaluisen,
työntyi seinään ja räjähti — puolen metrin etäisyydellä Kustun
päästä. Parin minuutin ajan oli kämpässä vain savua, sirpaleita,
sekasotkua. Isä V. oli lentänyt vasta-seinällä nukkuvan
ryhmänjohtaja H:n syliin; Kustu löysi itsensä puolipökertyneenä
sängynlaidalta pitelemässä päätään; ruokakuppeja, vaatteita,
tiilikiven sirpaleita, herra ties mitä oli lattialla; muuan naulassa
riippuva takki oli aivan mähjänä, hihat vain olivat säilyneet ehjinä…
Mutta kessään ei ollut pienintäkään naarmua, ja Setä, jonka vuoteen
vaihto oli pelastanut, hymyili tyytyväisenä ison nenänsä alta. —
Arvattavasti olivat ryssät nyt vasta keksineet kämpän, koska he
kaiken päivää pommittelivat sitä "aasin hännällään". (Aasinhännäksi
me nimitimme pientä tykkiä, joka oli sijoitettuna aikaisemmin
mainittuun niemeen ja jolla ryssä alituisesti meitä kiusasi,
singauttamalla pihahtavan pommin niskaamme silloin kuin sitä
vähimmän odotimme.) Ja lähelle he saivatkin sattumaan. Ei auttanut
enää muu kuin muuttaa asuinpaikkaa. Mutta tuskin oli ehditty
majoittua uuteen asuntoon, kun taaskin tulla tupsahti granaatti
sisään puhkaisten seinän — ja minun tekemäni vuoteen aivan
keskeltä. —

Toisinaan yltyi ryssä pommittamaan meitä koko voimallaan. Kuten


sanottu, olimme tuhoisalle sivutulelle alttiina ja oma tykistömme oli
venäläistä paljoa heikompi. Kerrankin tulla hurisi alueellemme noin
2,000 granaattia tunnin ajassa, saamatta aikaan mitään
mainittavampaa vahinkoa. Maassa oli tietysti kuoppa kuopan
vieressä, kämpät olivat säpäleinä — niinpä ei esim. kolmannessa
joukkueessa ollut yhtä ainutta ehjänä säilynyttä asuntoa — mutta
onnemme oli aivan satumainen, miehiin ei vain sattunut. Samainen
onni tuli ihan sananparreksi ja moni piti sitä selvänä merkkinä siitä,
että meillä vielä oli suoritettavana joku tärkeä tehtävä, koska kohtalo
näin säästeli voimiamme.

Mutta alituisessa jännityksessä saimme kyllä olla. Päällystön


tietoon oli tullut, että ryssillä olisi ollut aikomus hyökätä meidän
kohdallamme. Komppanian, jonka miesluku oli tavattomasti
harventunut, piti aina olla hälyytysvalmiina. Vartiot kovennettiin
kaksinkertaisiksi ja monena yönä oli koko komppania valveilla,
palellen Siperian suolla marraskuun pakastuvassa pimeydessä.
Vahtivuorot täytyi muuttaa nelituntisiksi. Miehistö kärsi vilua ja
ainaista väsymystä, mutta kiitettävän nöyrästi se tyytyi osaansa. Kun
astui yöllä kämppään ja rupesi ravistelemaan vahtimiehiä hereille,
niin monasti sai turvautua kovakouraisuuteen, joka teki pahaa. Ja
kun tuo ikäänkuin tainnoksissa maannut poika vihdoinkin pääsi
jaloilleen, katseli hän minuutin ajan kuin pökertynyt ympärilleen,
ennenkuin käsitti missä oli, mutta selvisi viimein, mumisi joskus
suomalaisen perkeleen, tarkoittamatta sillä erityisen pahaa ja alkoi
nopeasti suoriutua Siperian matkalle. Hauptmanni huhki kuin peikko
yö-pimeinäkin etuvarustusta tarkastamassa, oli levoton ja virkku,
ihan kuin muuttunut. Ystävällisesti hän taputteli poikiaan, kiitteli
heitä tuon tuostakin ja luultavasti huomasi, että vasta hyvyydellä hän
heitä hallitsi.

Tänä vaikeana aikana sattui meille onnettomuus, ainoa laatuaan


koko pataljoonassa: nuori Oden joutui ryssien käsiin. Eräänä
varhaisena aamuna — silloinkin oli läpi yön odoteltu hyökkäystä —
lähti toisen joukkueen päällikkö oberzugführer Ö. kuuden miehen
kanssa patrullille. Oikealla puolen etuvarustusta oli vetelä suo, jonka
takana, yhä enemmän oikealla, kohosi saksalaisten miehittämä,
lujasti varustettu kukkula. Mutta suon vasemmalla puolen, suoraan
meidän edessämme, kasvoi taajaa metsää ja tätä metsää myöten
etenivät tiedustelijat hiljaa ja varovasti. Oli tarkoitus saada selville,
mitä ryssät oikeastaan puuhasivat ja kuinka heidän etäällä oleva
vallinsa oikein kulki. Patrulli sivuutti rohkeasti ryssän
kenttävartiokämpän, joka näkyi Siperiaan, mutta jossa nyt ei
huomattu mitään liikettä. Sitten kulki se yhä kauemmas, kunnes
vihollisen rintavarustus alkoi näkyä. Ryssät siellä veistelivät ja
naputtelivat kaikessa rauhassa ja kun miehemme olivat sitä
katselleet ja ampuneet, kääntyivät he takaisin. Mutta yhtäkkiä oli
heitä vastassa noin 50 miestä kaaren muotoiseen ketjuun
hajaantuneina. Vartiokämpässä oli sittenkin ollut vihollisia, mutta
viisaasti olivat he pysyneet piilossa, laskeneet heikon patrullimme
ohitseen ja nyt tukkivat siltä paluutien. Hetkisen pojat taistelivat
urhoollisesti, mutta ylivoima oli liian suuri ja senlisäksi tuli se vielä
yllätyksenä. Ryssät päästivät raikuvan hurraan ja hyökkäsivät
pistimet tanassa saaliinsa kimppuun — tämä kaikki kuului ja näkyikin
vallan selvästi Siperiaan. — Onnettomuudeksi oli hauptmanni
kutsunut kaikki zugführerit puheilleen kämppäänsä, joten Siperiassa
ei ollut kuin tilapäisesti toimiva päällikkö, muuan nuori
ryhmänjohtaja. Tällä ei ollut kyllin rohkeaa päättäväisyyttä. Sillä jos
hän olisi nopeasti hyökännyt vihollisen selkään, olisi aseman
todennäköisesti voinut pelastaa ja ryssien olisi täytynyt paeta. Mutta
hän ei ollut tottunut omin päin toimimaan. Hän vain soitteli yhtä
mittaa hauptmannille, jonka rintaman takana ollen oli vaikeata antaa
ohjeita, kunnes kaikki oli liian myöhäistä. Sillä kun patrullin johtaja
huomasi uhkaavan vaaran, täytyi hänen viipymättä käskeä miehensä
pakoon. Tie oli kuitenkin poikki, eikä auttanut muu kuin peräytyä
vetelälle, avonaiselle suolle. Jos ryssillä olisi ollut harkintakykyä,
olisivat he ehdottomasti tappaneet joka miehen, ei olisi tarvinnut
muuta kuin pysyä paikallaan ja ampua minkä ennätti. Sensijaan he
ryhtyivät kiihkeään takaa-ajoon, juoksivat poikien perässä laukoen
turhaan pyssyjään, mihinkään osaamatta. Vaikka meikäläiset,
tultuaan suolle, joka vajotti yli polvien, vain vaivaloisesti ja hitaasti
pääsivät eteenpäin, huolimatta äärimmäisestä ponnistelustaan, eivät
rannalle pysähtyneet viholliset saaneet sattumaan. He olivat niin
hengästyttäneet itsensä, että heidän kätensä vapisivat, eivätkä he
enää jaksaneet tähdätä. Ainoastaan Oden kaatui. Suon reunassa oli
hänet vielä nähty, mutta senjälkeen ei kukaan tiedä hänen
kohtalostaan. Ryssät kantoivat hänet pois, liekö sitten kuolleena tai
elävänä. Toiset pääsivät näkymättömiin vaivaismäntyjen ja ruohon
taa. Mutta vielä oli heidän käydä hullusti. Sillä kun saksalaiset
äskenmainitulta kukkulalta huomasivat suossa rämpivät miehet,
pitivät he näitä ryssinä ja alkoivat ampua kuularuiskullaan. Vasta
tunnussanan huudot ja jääkärien takin väri ilmaisivat heille
erehdyksen ja pojat pääsivät vihdoinkin turvaan, puolikuolleina
väsymyksestä. — Mutta kadonnutta Odenia oli lähdettävä etsimään.
Koottiin uusi joukko, painuttiin suolle ja tutkittiin äskeiset jäljet,
mutta missään ei häntä näkynyt. Vähältä vain piti ettei tämä
toinenkin patrulli joutunut tuhon omaksi. Sillä ryssä alkoi ampua
vietävästi granaatteja. Niitä putoili kaikkialle tuhkatiheään, mutta suo
oli onneksi niin pehmeää, että ne vajosivat syvälle maahan ennen
räjähtämistään, eivätkä tuottaneet kenellekään vahinkoa… Nuori
toverimme oli auttamattomasti menetetty; me toivoimme vaan, että
hän olisi saanut kuolettavan luodin, jotta ei vihollinen olisi enää
voinut haavoittunutta kiduttaa. —

*****

Komppanian voimat olivat niin äärimmilleen pingoitetut, ettei se


kauan olisi jaksanut kestää tällaista rasitusta. Yhtämittainen
yövalvonta oli heikontanut miehet ja alituinen jännitys oli koskenut
siinä määrin hermostoon, että pari rintama-elämälle ominaista
sairaustapausta oli sattunut. Nämä potilaat, jotka ennen olivat
osoittautuneet moitteettomiksi sotilaiksi, alkoivat tavallaan pelätä.
Eikä oikeastaan niinkään, he vain vavahtelivat, jos kuulivat pommin
räjähtävän, ja laukausten pamahdellessa he tunsivat outoa
voimattomuutta ja alkoivat väristä.

Me tiesimmekin jo etukäteen, että pian päästäisiin lepäämään. Ja


vihdoin koitti odotettu hetki. Joulukuun 19 päivänä marssivat ne
saksalaiset, jotka siirrettiin meidän tilallemme — heitä oli muuten
ainakin puolet enemmän kuin meitä — Dumbeen, ja meille annettiin
lähtökäsky. Mutta vielä oli minun poloisen käytävä Siperiassa. Kun
nimittäin saksalaisten vartiopäällikkö tuli kysymään
zugführeriltämme, kuinka etuvarustukseen oli mentävä, ei
päivystävää ryhmänjohtajaa näkynyt missään ja minut, joka
onnettomuudekseni seisoin aivan lähellä, määrättiin oppaaksi. Olin
sen seitsemät kerrat käynyt Siperiassa sekä yöllä että päivällä,
pommisateessa ja luotien vinkuessa, mutta koskaan en ollut
taivaltanut sinne levottomampana kuin nyt. Ryssä ei edes
yrittänytkään ampua, mutta siunatkoon kuinka pelkäsin. Sellaisen
elämänhalun oli tietoisuus vapaaksi pääsystä yhtäkkiä synnyttänyt.
Ja kun työ oli tehty, niin oikein hengähdin helpoituksesta. —

Marssittiin Tuckumiin, missä komppaniat täydennettiin ja


järjestettiin uudestaan. Sieltä matkusti pataljoona junalla Libauhun.
Ainoastaan tykistö oli jäänyt rintamalle.
V.
KOTIA KOHTI.

1.

BERLINIIN.

Libaussa meidät majoitettiin venäläisiin kasarmeihin, joiden salit


olivat niin avaria, että kokonainen komppania mahtui samaan
huoneeseen. Kovin mukavia eivät ne silti olleet, sillä tavaroille ei ollut
sopivia säilytyspaikkoja, ja kun miehiä oli niin paljon yhdessä, syntyi
siitä hälinä, joka saattoi käydä kiusaavaksi. Hanuri räikyi yhtämittaa,
toiset tanssivat, toiset pelasivat korttia, mutta rauhassa ei saanut
kukaan olla.

Millaiseksi olo lopulta muodostui tässä vanhassa kaupungissa,


jossa pataljoona majaili niin kauan, sitä en tarkemmin tiedä, sillä jo
seuraavana päivänä sain zugführeriltä ilmoituksen, että minut oli
komennettu Berliniin. Tietysti olin iloissani, sillä kasarmi-elämä ei
ollut mitään herkkua, sen tiesin jo Lockstedtin ajoilta. Lähtö oli
tapahtuva yöllä; meitä oli kaikkiaan kuusi määrätty matkaan.

Mutta rikkiviisas kaitselmus tahtoi pitää huolta siitä, että mieleeni


painuisi edes hämärä käsitys Libaun kaupungista. Kun nimittäin
kävimme pataljoonan schreibstubessa noutamassa asiaankuuluvat
paperit ja matkaliput, ilmoitti siellä joku suuri herra haluavansa
lähettää joulukinkun kotiinsa — nähtävästi hän oli saanut täältä
halvalla sen ostaa — ja kysyi minulta, joka lienen osannut paraiten
saksaa, enkö tahtoisi illemmalla käydä noutamassa tuota pakettia,
toimittaakseni sen perille. Ja sillä matkalla minä eksyin. Viitisentoista
kiloa painava siankoipi kädessäni harhailin Libaun sokkeloisia ja
kapeita katuja noin parin tunnin ajan. Yrittelin kyllä kysellä
saksalaisilta sotilailta tietä, mutta ainakin yksi neuvoi kokonaan
harhaan ja ehkä juuri siitä syystä jouduin ihan toiselle puolen
kaupunkia. Viimein sain erään vanhanpuolisen herran saattamaan
itseäni, mutta olin taas nääntyä tämän ystävällisen miehen
loputtomaan uteliaisuuteen. Muistinpa moneen kertaan Haitari-Jalin
ainaista laulua:

Kori käsivarrella Lontoon kaduilla


täytyi minun kaupitella
ostraliaa.

Jonka vain olisin halunnut muuttaa:

Siankoipi kainalossa Libaun kaduilla


täytyi minun etsiskellä
kortteeria.

Kun vihdoin päädyin kasarmille, olivat kaikki jo nukkumassa ja


lähtö-aika oli tuota pikaa käsillä. Tallustelimme öistä katua hynttyyt
seljässä — minulla senlisäksi siankoipi — asemalle ja jäimme
odottelemaan junan lähtöä. Mutta kuinka ällistyimmekään, kun
ovivahti, joka tarkasti matkustajien paperit, ilmoitti meille, että tämä
juna kuljetti ainoastaan lomalle-menijöitä, eikä ketään muuta. Selitin
hänelle, että meidät oli komennettu Berliniin, että meillä oli ylen
tähdellisiä asioita ja että meidän oli välttämättömästi päästävä
mukaan. Mutta siitä ei ollut mitään apua. "Menkää
komandantuuriin", kuului virallinen kehoitus olkapäänkohauksineen.
Pyysin tovereitani odottamaan ja syöksyin kuin tuulispää
komendantin luo, missä uudistin selitykseni. Nuori, kalpea,
intelligentin näköinen luutnantti, jonka kasvoilla liikkui alituiseen
hermoväreitä, suhtautui esitykseeni sangen rauhallisesti ja alkoi
kysellä kotimaastani. Sain hänet kumminkin telefonoimaan
pataljoonan päämajaan, mutta sieltäkään ei vastattu. Sitten siirtyi
hän keskustelemaan suomenkielen sijoista, joita sain hänelle luetella
minkä ennätin. Ja kun väliin rohkenin kysästä, mitenkä sen matkan
laita oikeastaan oli, koki hän vain mielenkiinnolla komitatiivia ja
instruktiivia, ja oli sangen tyytyväinen, kun oli saanut tietääkseen,
että unkarinkieli on meikäläisen sukulainen. Mutta jo vihelsi juna. Ja
silloin, vilkaisten hätäisesti kelloaan, luutnantti hypähti ylös, käänsi
minut olkapäistäni kuin lukkari taulun ja huusi:

— Marsch! Kommen Sie mit! (Tulkaa mukaan).

Juoksujalkaa riennettiin asemasillalle, komendantti puhalsi


kimeään pilliin nostaen kätensä ja liikkeelle lähtenyt juna pysähtyi
heti.

— Jääkärit tulevat junaan, ilmoitti hän sitten, vastasi ystävällisesti


kunniantekooni ja jäi katselemaan, kuinka kuusi suomalaista
jöröjukkaa vääntyi kaikessa rauhassa vaunuun. Meidän
itsetuntoamme tietysti hiveli, kun matkustajat katselivat meitä
kummeksuen ja varmaankin aprikoiden, jotta mitähän suuruuksia
nuo ovatkaan, kun niille junatkin seisotetaan. Mutta visusti varoimme
sitä näyttämästä.

Olipa se matka. Juna oli ihan ahtamalla ahdettu miestä täyteen.


Istumapaikasta ei ollut toivoakaan, mutta hyvä niinkin. Pääasia oli,
ettei meidän tarvinnut kääntyä takaisin kasarmille. —

*****

Meistä ei ollut kukaan käynyt Berlinissä. Tiesimme kuitenkin niin


paljon, että pysähdyspaikkamme oli Zologischer Banhof ja kun juna
porhalsi mainitulla asemalle, astuimme tyytyväisinä ulos ja
ilmoittauduttuamme aseman komendantille lähdimme etsimään
pataljoonan konttoria tästä maailmankaupungista. Raitiotievaunu,
joka meille ystävällisesti neuvottiin, vei miltei perille asti. Siinä oli nyt
vihdoinkin Kurfürstenstrasse, tuossa numero 148, tuossa osotekilpi:
Ausbildungstruppe Lockstedt, jota nimeä toimistomme Berlinissä yhä
käytti. Noustuamme leveitä herrasportaita näimme vihdoin oven
päällä: Graf Schwerin, joka oli nykyinen majurimme, ja tiesimme
olevamme oikeassa paikassa.

Muutamia huoneita oli varustettu samaan malliin kuin ennen leirillä


kaksinkertaisine sotilasvuoteineen. Näissä asui lomallakävijöitä. Kun
miehillä yleensä oli niin vähän rahaa, että vaikka heille rintamalta
myönnettiin parin viikon loma, eivät he voineet minnekään lähteä, oli
tähän taloon varattu heille ilmainen asunto. Näillä vuoteilla mekin
vietimme ensimäisen yömme, sillä oli jo ilta. — Sitä ennen olin
kuitenkin jättänyt siankoiven, jota niin uskollisesti olin kuljettanut
mukanani, toimitettavaksi oikealle omistajalleen.
2.

NAPA.

Seuraavana päivänä oli tietenkin ilmoittauduttava asianomaiselle


luutnantille, halusipa itse kreivikin meitä tervehtää. Mutta kun
katsahdin ympärilleni konttorihuoneessa, johon meidät mainittua
tarkoitusta varten oli osoitettu, niin mitä näinkään: Siankoipi,
vaivaloinen matkakumppanini, oli päästetty paperikapaloistaan ja
suuri lovi paistoi sen ruskeassa kyljessä. Ja kun luutnantti oli
mennyt, kyseli saksalainen kirjuri, pureskellessaan leipäpalaa, jonka
valtavana yläpuoliskona komeili mehuisa kinkunviipale, hyvin
huvitetun näköisenä.

— Tekö toitte paistin?

— Niin.

— Ettekö tiennyt, ettei sellaista ole lupa kuljettaa mukanaan?


Kuinka ihmeessä ei sitä otettu teiltä pois?

— Noudatin määräystä. Ja näkyipä tuo vaan tänne asti onnellisesti


päässeen.

Hän katseli minua pitkään ja hänen silmänsä kuvastivat eräänlaista


surumielistä ylenkatsetta, ikäänkuin olisi hän tahtonut sanoa: kovin
olet vielä outo, nuori mies.

— Se on hyvää, ettekö tahdo maistaa? kysyi hän vihdoin.

Ajattelin ensin sanoa: ei maita, kiitos, mutta sitten päättelin, että


mitäpäs sitä joutavia ja leikkasin aika viipaleen käteeni. Kelpasi sitä
sotamiehen pureskella. —

Kun jälleen palasimme siihen huoneeseen, jossa olimme olleet


yötä, kohtasi meitä ilahduttava näky. Kymmenkunta entistä
toveriamme, joita olimme tottuneet katselemaan vain jääkärin
univormussa, seisoi nyt edessämme siviilivaatteissa täydellisinä
herrasmiehinä, kovat kaulassa, tukka hienosti kammattuna, kasvot
sileiksi ajettuina, housut prässättyinä ja kengät kiiltävinä. Ja
tervehtiessään he tekivät kumarruksen, jota kauppa-apulainen olisi
voinut kadehtia. He olivat saaneet komennuksen Berliniin jo ennen
meitä, ja olivat olleet täällä noin viikon päivät. Syntyi iloinen ja vilkas
sananvaihto, jonka kuitenkin pian keskeytti ovikellon soitto ja
hiljainen varoitus:

— Napa tulee!

Sisään astui keski-ikäinen ja -kokoinen, lihavahko herrasmies,


salkku kainalossa. Punertavan naaman ollessa yhtenä hymynä hän
tervehti meitä ja viittasi seuraamaan itseään erääseen
sivuhuoneeseen.

Kun olimme istuutuneet paikoillemme, veti hän otsansa


arvokkaihin ryppyihin, asetti etusormensa nenälleen ja mietti
hartaasti, tekemättä kuitenkaan oikein nerokasta vaikutusta. Hän oli
arvoltaan insinööri, ja sen retkikunnan johtaja, johon me kaikki
kuuluimme. Omien sanojensa mukaan oli hän matkustellut
pohjoisessa, aina Grönlannissa asti, ja merkiksi tästä napaseutujen
tuntemuksesta sekä myöskin siitä keskeisestä asemasta, joka hänellä
meihin nähden oli, olivat pojat ruvenneet kutsumaan häntä Navaksi.
Hän väitti ymmärtävänsä ruotsia ja osaavansa auttavasti venäjää ja
tätä viimemainittua kieltä, jota me emme luonnollisestikaan voineet
sietää, hän alinomaa meille tyrkytti.
Mietittyään aikansa laski hän meidät juhlallisesti:

— Kuusitoista, siis kaikki.

Ja sitten otti hän muistikirjansa ja merkitsi sinne huolellisesti, että


miesluku oli täysi.

Alkoi uusien tulokkaiden kuulustelu, minun joutuessani


ensimäiseksi tuleen.

Olinko kulkenut Suomessa talvella?

Luonnollisesti.

Olinko kulkenut myöskin pohjoisessa?

Olin pohjoisessakin.

Olinko hiihtänyt?

Tietysti.

Olinko käynyt Inarissa tai Kuolassa asti?

En.

Kittilässä sitten?

— Sano hemmetissä olleesi, siitä se tykkää, kuulen toverini


kuiskaavan.

Olen ollut Kittilässä. Osaanko ajaa poroa?

— Sano hiidessä… Välttävästi.


Napa otti jälleen muistikirjan esille ja teki sinne merkintöjään.
Sitten seurasi toisten kuulustelu, samaan malliin. Ja aina tuli
merkintöjä kirjaan. Kun keskustelumme jatkui ja kaikenkaltaisia
mitättömyyksiä esiteltiin, sai taskukirja, jota ehtimiseen täytyi hakea
milloin toisesta, milloin toisesta taskusta, riistä osansa, sormi
lennähti nenänpäähän ja otsa rypistyi. En ihmetellyt ollenkaan, että
kun lyijykynä sattui putoamaan ja se syvään kumartaen ojennettiin
Navalle, muuan pojista hiljaa mutisi.

— Paneekohan tuo tuonkin muistiin?

Alkoi esitys retkestämme. Kartalta Napa näytti tien ja ryhtyi sitten


selostamaan yksityiskohtia, käyttäen meikäläistä johtajaa tulkkinaan.
Kuuntelin sitä tarkkaavasti pitkän aikaa, mutta mitään uutta ei
ilmaantunut ja seikkoja, jotka olivat itsestään selviä, teroitettiin
mieleen kuin kielioppia koulussa. Tulin hajamieliseksi ja ajatukseni
siirtyivät menneihin aikoihin. Muistin kiertokoulua… Herra siunatkoon
vanhaa kiertokoulunopettajaa…

Kun tunti oli umpeen kulunut, nousi Napa, luvaten seuraavana


päivänä jatkaa; pitkän aikaa me vaelsimme joka aamu kuulemassa
näitä esitelmiä. Mutta tällä kertaa oli työ lopussa ja me uudet miehet
saimme lähteä ostamaan itsellemme siviilipukuja. Ei kuitenkaan omin
päin; erityisesti tähän toimeen komennettu herra tuli mukaamme,
määräsi kuinka kalliita tarpeemme korkeintaan saattoivat olla ja
suoritti laskut. Hienoiksi se silti veti miehet, vaikka ei tavara
ollutkaan niin ensiluokkaista.

Sitten annettiin pojille seuraavan malliset komeat olo-todistukset.

"Jääkäri N.N. 27:stä jääkäripataljoonasta on komennettu Berliniin


Yli-esikunnan palvelukseen. Hänellä on oikeus käyttää siviilipukua ja
viran puolesta kehoitetaan kaikkia virkamiehiä osoittamaan hänelle
avuliaisuuttaan."

Siinä oli paperi, jota kelpasi näyttää ja joka kaikkialla teki


vaikutuksensa. Kun vielä oli saatu runsas palkka, 10 Saksan markkaa
päivältä, jolla kuitenkin piti maksaa asuntonsa ja ruokansa ja joka
annettiin kolmeksi päiväksi kerrallaan, kiiruhdimme hakemaan
itsellemme huoneita. Oli tämä toki toista kuin vaivaiset 53 penniä
rintamalla! Myöhemmin kuitenkin huomasimme, että nytkään ei
voinut syödä lähimainkaan kyllikseen, mikäli halusi pysyä
kohtalaisessa tupakassa.

*****

Oltiin menossa Berlinin harjoituskentälle, jossa meitä koulutettiin


"pommareiksi". Tällä nimellä kutsuttiin yleisesti niitä miehiä, jotka
olivat erityisesti opetetut käyttämään kaikenkaltaisia helvetinkoneita,
tulensytyttäjiä ja käsipommeja, sekä tämänlisäksi särkemään siltoja,
telefoonijohtoja, vetureita j.n.e. Heitä lähetettiin Suomeen
ehkäisemään ryssien ampumatarpeiden kuljetusta ja tuottamaan
viholliselle muutakin vauriota.

Vanhalla kokoontumispaikallamme Potsdamer- ja Bülow-katujen


risteyksessä, seisoi miesjoukko täysilukuisena. Ei kuitenkaan yhdessä
rykelmässä, vaan kaksi tai kolme paikassaan, mitkä kävellen
lähettyvillä, mitkä keskustellen. Jo saapui Napa. Pojat nostivat
hattuaan.

— Strastvuite! sanoi hän hymyillen lähimpänä seisoville.

— Emme ymmärrä venäjää, huomauttaa suomalainen johtaja


loukkaantuneena.
Sitten Napa viheltää ja viittaa kädellään. Se on lähtömerkki. Mutta
poikia ei moinen koiran kutsu lainkaan miellytä ja ikäänkuin tästä
huomauttaakseen alkavat he matkia, viheltää ja viittoa käsillään.

Ennestään jo tiedetään, ettei sovi kulkea joukossa. Osa painuukin


toiselle puolen katua, mutta lähestyvät siellä liiaksi toisiaan. Jo
kuuluu jälleen vihellys — herättäen varmasti enemmän huomiota
kuin koko meidän pieni sakkimme — ja Napa viittaa tulkin
puheilleen.

— Sanokaa, etteivät pojat kävele yhtä jalkaa. Siitä näkee heti, että
he ovat sotilaita.

— Ymmärrän.

— Pitää olla varovainen, äärettömän varovainen. Meidän


ekspeditsioonimme on niin suurenmoinen ja vaarallinen. Selittäkää
se heille.

Pojat tietysti lakkasivat käymässä tahdissa ja hajaantuivat kuin


poliisin käskystä. —

Kentällä oli hälinää. Yhdessä kohden harjoitettiin miehiä, toisessa


pionieritöitä. Tuolla toimi tulensyöksijä-kone, jota en milloinkaan ollut
nähnyt, mutta josta olin lukenut niin ihmeellisiä kuvauksia; pauhaten
kuin meri se syöksyi kidastaan mustanpunaisen tulivirran, joka eteni
tavattomalla nopeudella pyörien kuin lumivyöry ja kasvaen
parikymmentä metriä korkeaksi. Sen läpi ei kukaan voinut elävänä
päästä…

Ja täällä opetettiin nyt meille pomminkäyttöä, seliteltiin


helvetinkoneita ja sytytyskeinoja aito saksalaisella täsmällisyydellä,
Navan katsellessa tyytyväisen näköisenä sivummalta. Ei riittänyt se,
että joku seikka perusteellisesti neuvottiin, itse sai sen suorittaa,
olipa tehtävä sitten kuinka vähäpätöinen tahansa. Niin paksupäistä
ihmistä ei ole, ettei saksalainen saisi häntä oppimaan. —

Poislähtiessämme kehoitti Napa meitä nopeasti hajaantumaan.

— Ja olkaa varovaisia, muistakaa se. Meidän yrityksemme on niin


vaarallinen. Vihollisella ei saa olla pienintäkään aavistusta siitä.
Varokaa sanojanne kahviloissa ja yleisissä paikoissa. Puoli lausetta
voi turmella kaiken.

Kieltämättä hän oli oikeassa, suunnitelmamme oli rohkea ja


vaarallinen. Mutta eihän meistä osannut saksaa kuin viisi kaikkein
luotetuinta miestä. Ei siis ollut suurta pelkoa meidän puoleltamme.
Paljoa enemmän olisi Napa saanut varoa niitä miehiä, jotka toimivat
Ruotsissa matkaamme valmistelemassa. Suurilla kerskumisillaan ja
loistavilla riimillään he pettivät häntä ja pistivät taskuunsa ne rahat,
joita heille niin runsaasti tuhlattiin. Ainakin he toimivat leväperäisesti.
Meitä ei päästetty sinne, meihin ei ehkä niin paljoa luotettu, mutta
varsinaisiksi työn suorittajiksi, siis vaaraan, kelpasimme kyllä. Kenties
siinä on epäonnistumisen perussyy. — Mutta luulen, ettei minulla ole
oikeutta selitellä yksityiskohtia, eikä lähemmin kertoa itse
suunnitelmastakaan.

3.

BERLININ PIKKUPORVAREITA.
Toverini M. ja minä keksimme verrattain hauskan asunnon Pension
N. N:stä, Potsdamerstrassen varrelta. Täysihoito maksoi ainoastaan
3: 50 Saksan markkaa vuorokaudelta ja ruoka kävi laatuun, ainakin
jääkärille, vaikka sitä saikin jotakuinkin niukasti.

Jo huonetta vuokratessamme olivat pensionin neitoset näytelleet


omaa osaansa. Kauppaa oli tehnyt itse omistaja, vanha,
teräväkielinen, ryppyinen leskirouva, joka osasi sekä torua että olla
ystävällinen, mutta tavan takaa oli hänen täysi-ikäinen tyttärensä
pyörähtänyt saapuville milloin minkin tekosyyn varjolla ja heittänyt
poistuessaan ihanimman katseensa suurista, kauniista silmistään.
Olipa toinenkin neitonen, miehestään erossa elävä nuori rouva —
seikka, joka meille selvisi tietysti vasta aikojen kuluttua — luonut
meihin oven rakosesta lumoavan silmäyksen. Luulen kuitenkin, että
jo hinnan huokeus oli riittävänä vaikuttimena päätöstä tehdessä.
Aluksi meitä hieman tuskastutti se pikkutarkkuus, jota emäntä
osoitti. Olimme kylläkin tottumattomia käsittelemään kaiken
maailman leipä-, liha-, peruna-, voi-, sokeri- ja herra ties mitä
kortteja, mutta laskelmiemme mukaan olisi annosten pitänyt olla
suurempia. Ja kun vanha akka toi tämän määräperäisen aterian
pöytään, muisti hän aina sanoa:

— Syökää nyt kylliksenne, lapset.

Sensijaan ei meidän suinkaan tarvinnut olla seuran puutteessa,


siitä pitivät nuoret naiset kyllä huolta. Huoneessamme oli piano, jota
Else-neiti, talon tytär, soitti, vieläpä hän kaikeksi onnettomuudeksi
lauloikin. Suomalaisesta musiikista riitti pakinaa niin paljon kuin
kielitaitomme suinkin myöten antoi, ja meitä pyydettiin hartaasti
ostamaan suomalaisten säveltäjien teoksia. Vihdoin täytyi minun
uhrata vähäisistä rahoistani ja kun en löytänyt sillä kertaa muuta,
otin Sibeliuksen Valse tristen, vaikka hyvin tiesinkin, että tämä
suurenmoinen kappale oli neidille aivan ylivoimainen. Ja nytkös alkoi
harjoittelu ja tankkaus.

— Tämä on todellakin surkeata, huokasi toverini maaten


leposohvalla selällään.

— Valse triste… tietysti! sanoin.

— Minä en ole koskaan oikein ymmärtänyt musiikkia. Mutta kovin


se käy vatsan päälle.

— Mitä te sanotte? kääntyi taiteilijatar kysymään. Ja meidän piti


vakuuttaa, että esitys yhä parani ja että sen synkkä tuntu ihan karmi
toveriani, kuten todellinen kuoleman läheisyys. —

Mutta pian meille selveni tämän alituisen seuranpidon salaisuus.


Tuli nimittäin sunnuntai monine tavanmukaisine vieraineen. Ja kaikki
nämä puotipojat, konttoristit ja konekirjoittajattaret tuotiin meidän
huoneeseemme, noin ilman muuta vain. Puolesta päivin iltamyöhään
saakka oli siellä yhtämittaista naurua ja keskustelua, meidän
paperossimme näkivät kyytinsä, kun niitä polttivat sekä naiset että
herrat, puhumattakaan viinipullosta, jonka olimme viikon säästöillä
ostaneet ja joka nyt kuivui heti alussa. Meitä tuskastutti. Olimmehan
me vuokranneet tämän huoneen, eihän se seikka, että täällä oli
piano, oikeuttanut moiseen menettelyyn. Mutta sitten me lopultakin
älysimme: perhekunnalla, johon kuului vain nuo kolme naista, ei
ollut mitään vierashuonetta, yleensä mitään muuta paitsi keittiö,
kaikissa asui vuokralaisia. Hehän nukkuivat vaatekomerossa, sen
olimme jo varemmin huomanneet. —
Monasti iltaisin, kun paitahihasillamme ja avojaloin istuimme
lukemassa, tulivat neitoset sisään kuin kotiväki ainakin, ja se ei vielä
mitään: he tulivat vuoteitten ääreen naureskelemaan, kun jo olimme
peitteiden alla, polttelivat, kohentelivat asentoamme mukavammaksi
ja nuori rouva näkyi pussaavankin toveriani. Joka luulee, että he
olivat kevytmielisiä naisia, erehtyy kuitenkin täydellisesti. Tämä
kaikki oli vain asiaan kuuluvaa sydämellisyyttä, mutta ei mitään
enempää.

Se seikka, että meidän paperossimme ja kaikki, mitä meillä suinkin


oli, aina oli avoimesti tarjolla, näkyi kuitenkin tekevän omanlaatuisen
vaikutuksen heihin, ja kun me sen lisäksi kuvailimme suomalaisia
oloja ja tuhlaavaisuutta liioittelevalla tavalla, alkoivat ruoka-annokset
pian kasvaa ja monesti neitoset lennättivät vanhalta akalta salaa
meille brödchenin, pienen pullan, jonka väliin he, ties mistä, olivat
sipaisseet voita. Elämä muuttui mukavammaksi, vaikka siitä tosin
puuttui rauha. Sensijaan tarjosi se oivallisia tilaisuuksia seurata
puotipoikien ja keikailevien konttoristein kuhertelua,
mustasukkaisuutta, joka maksoi meille niin tavattomasti paperosseja.

*****

Jouluaattona, vähää vaille seitsemän illalla, kun juuri olimme


laittamassa itseämme mahdollisimman hienoiksi, syöksyivät
molemmat neitoset sisään ilosta säteilevinä ja käsiään taputtaen.

— Te tulette mukaan, eikö totta? Tulettehan mukaan? huusivat he


kuin yhdestä suusta.

— Mihinkä niin?
— Meitä on kutsuttu vierailulle. Oi, kuinka hauskaa!
Steglitzerstrasse 20. Teidän suomalaiset toverinne ovat kutsuneet.
Juuri nyt tuli sana… Tietysti te tulette mukaan.

Mieleeni muistui kotoinen joulu, jota pidetään perhejuhlana ja


jolloin vierailu on sopimatonta. Täällä näytti olevan toisin. Mutta
majurimme, kreivi von Schwerin oli sitäpaitsi kutsunut kaikki
suomalaiset toimistoon yhteistä joulua viettämään ja meidän oli
kiiruhdettava sinne.

— Mahdotonta. Herra kreivi on kutsunut meidät luokseen,


vastasimme.

Vanha akka oli myöskin tullut huoneeseen ja tarttui nyt kiihkeästi


keskusteluun.

— Kuka on kutsunut?

— Kreivi von Schwerin, majurimme.

— Aaah!… Kreivi on kutsunut!…

Kaikkien kasvoilta kuvastui kunnioituksen sekainen hämmästys,


joka kohdistui meihin. Mitähän me oikeastaan olimme, kun itse kreivi
kutsui? Me olimme aina niin salaperäisiä, emme puhuneet koskaan
puuhistamme, emmekä näyttäneet juuri tekevänkään mitään, mutta
rahaa meillä oli. Tuskin tiedettiin muuta kuin että olimme
suomalaisia. Ja poliisikin, jolle oli täytynyt asunnostamme ilmoittaa,
oli merkitsevästi vastannut emännälle: "Niin, kyllä tiedän."

Neitoset muuttuivat totisiksi ja silmiin kihosi kosteus.


— Mutta myöhemmällä sitten. Ettehän te kauan viivy kreivin
luona? Steglitzer 20, muistakaa. Tulette vain portille, kello 9 tai 1/2
10, me olemme vastassa. Luvatkaa toki!

Me sanoimme tulomme riippuvan kreivistä ja riensimme


matkoihimme.

Toimiston suureen huoneeseen oli tuotu joulukuusi ja katettu


valkea pöytä. Kreivi itse puolisoineen otti meidät ystävällisesti
vastaan. Hän oli pitkä ja vielä ryhdikäs, mutta iäkäs ja
harmaapartainen herra, joka varhaisemminkin oli osoittanut
meikäläisille erikoista ystävällisyyttä, vieläpä antanut rahaakin pulaan
joutuneille. Kun oli asetuttu pöytään, piti hän meille sydämellisen
puheen, jossa hienolla tavalla kosketeltiin kotimaatamme. Seurasi
pari muuta puhetta. Sitten tarjottiin teetä ja vehnäleipää, jota
hallitus oli antanut jouluksi valmistaa ympäri koko Saksan, ja majuri
kehotti poikia olemaan mahdollisimman iloisella päällä.

Kuten tällaisissa tilaisuuksissa yleensä, oli nytkin mieliala hiukan


painuksissa. Jotakin jäykkää, miltei ikävystyttävää kuulsi läpi
teennäisen rattoisuuden, ja kun kreivi puolisoineen oli mennyt,
päätimme toverini ja minä noudattaa neitosten kutsua. Ainakin
kymmenen minuuttia kävelimme Steglitzer 20:n porttikäytävän
edessä, mutta ketään ei tullut, vain melua ja naurua kuului ylhäältä
läpi ikkunoiden. Tarkastelimme osotekilpiä… Pension Y. Ahaa,
tässähän tosiaan asui neljä amiraali-esikunnan poikaa, jotka olivat
olleet poissa juhlasta. Mutta meille he olivat melkoisen vieraita ja nyt
oli joulu, varmaankin olisi sopimatonta häiritä heitä, eiväthän he itse
olleet meitä kutsuneet. Joku tuli portista alas… Else neiti näkyi
olevan. Mutta me olimme jo kaukana; olimme muuttaneet
suunnitelmamme.
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.

More than just a book-buying platform, we strive to be a bridge


connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.

Join us on a journey of knowledge exploration, passion nurturing, and


personal growth every day!

ebookmasss.com

You might also like