Learning PHP MySQL JavaScript CSS and HTML5 A Step by Step Guide to Creating Dynamic Websites 3rd Edition by Robin Nixon ISBN 1491906979 9781491906972 download
Learning PHP MySQL JavaScript CSS and HTML5 A Step by Step Guide to Creating Dynamic Websites 3rd Edition by Robin Nixon ISBN 1491906979 9781491906972 download
https://ebookball.com/product/machine-learning-step-by-step-
guide-to-implement-machine-learning-algorithms-with-python-1st-
edition-by-rudolph-russell-isbn-9781719528405-16086/
Learning Web Design A Beginner Guide to HTML CSS JavaScript and Web
Graphics 5th Edition by Jennifer Niederst Robbins ISBN 1491960159
9781491960158
https://ebookball.com/product/learning-web-design-a-beginner-
guide-to-html-css-javascript-and-web-graphics-5th-edition-by-
jennifer-niederst-robbins-isbn-1491960159-9781491960158-16006/
https://ebookball.com/product/research-methodology-a-step-by-
step-guide-for-beginners-3rd-edition-by-ranjit-
kumar-1849203016-978-1849203012-17356/
https://ebookball.com/product/teaching-psychology-a-step-by-step-
guide-3rd-edition-by-douglas-bernstein-sue-frantz-stephen-
chew-9780367143947-15176/
Excel VBA Step By Step Guide to Learning Excel Programming Language
for Beginners 1st Edition by Jason Jay ISBN 1976198127 9781976198120
https://ebookball.com/product/excel-vba-step-by-step-guide-to-
learning-excel-programming-language-for-beginners-1st-edition-by-
jason-jay-isbn-1976198127-9781976198120-15878/
https://ebookball.com/product/java-easy-java-programming-for-
beginners-step-by-step-guide-to-learning-java-1st-edition-by-
felix-alvaro-isbn-1539509362-9781539509363-15874/
https://ebookball.com/product/how-to-use-spss-a-step-by-step-
guide-to-analysis-and-interpretation-4th-edition-by-brian-
cronk-188458568x-978-1884585685-14632/
https://ebookball.com/product/java-programming-a-beginners-guide-
to-java-step-by-step-1st-edition-by-troy-
dimes-1507562942-978-1507562949-17382/
Learning PHP and MySQL 1st edition by Davis, Michele, Phillips, Jon
9780596101107, 0596101104
https://ebookball.com/product/learning-php-and-mysql-1st-edition-
by-davis-michele-phillips-jon-9780596101107-0596101104-12444/
Learning PHP, MySQL,
JavaScript, CSS & HTML5
Robin Nixon
DEDICATION
For Julie
Preface
Audience
This book is for people who wish to learn how to create effective and
dynamic websites. This may include webmasters or graphic
designers who are already creating static websites but wish to take
their skills to the next level, as well as high school and college
students, recent graduates, and self-taught individuals.
In fact, anyone ready to learn the fundamentals behind the Web 2.0
technology known as Ajax will obtain a thorough grounding in all of
these core technologies: PHP, MySQL, JavaScript, CSS, and HTML5.
Assumptions This Book Makes
This book assumes that you have a basic understanding of HTML
and can at least put together a simple, static website, but does not
assume that you have any prior knowledge of PHP, MySQL,
JavaScript, CSS, or HTML5—although if you do, your progress
through the book will be even quicker.
Supporting Books
Once you have learned to develop using PHP, MySQL, JavaScript,
CSS, and HTML5, you will be ready to take your skills to the next
level using the following O’Reilly reference books. To learn more
about any of these titles, simply search the O’Reilly website or any
good online book seller’s website:
Dynamic HTML: The Definitive Reference by Danny Goodman
Italic
Indicates new terms, URLs, email addresses, filenames, file
extensions, pathnames, directories, and Unix utilities.
Constant width
Indicates command-line options, variables and other code
elements, HTML tags, macros, and the contents of files.
NOTE
This element signifies a tip, suggestion, or general note.
WARNING
This element indicates a warning or caution.
Using Code Examples
Supplemental material (code examples, exercises, etc.) is available
at http://lpmj.net.
This book is here to help you get your job done. In general, if
example code is offered with this book, you may use it in your
programs and documentation. You do not need to contact us for
permission unless you’re reproducing a significant portion of the
code. For example, writing a program that uses several chunks of
code from this book does not require permission. Selling or
distributing a CD-ROM of examples from O’Reilly books does require
permission. Answering a question by citing this book and quoting
example code does not require permission. Incorporating a
significant amount of example code from this book into your
product’s documentation does require permission.
We appreciate, but do not require, attribution. An attribution usually
includes the title, author, publisher, and ISBN. For example:
“Learning PHP, MySQL, JavaScript, CSS & HTML5, Third Edition, by
Robin Nixon. Copyright 2014 Robin Nixon, 978-1-4919-4946-7.”
If you feel your use of code examples falls outside fair use or the
permission given here, feel free to contact us at
[email protected].
We have a web page for this book, where we list errata, examples,
and any additional information. You can access this page at
http://bit.ly/lpmjch_3e.
There is also a companion website to this book at http://lpmj.net,
where you can download all the examples from this book in a single
zip file.
To comment or ask technical questions about this book, send email
to [email protected].
For more information about our books, courses, conferences, and
news, see our website at http://www.oreilly.com.
Find us on Facebook: http://facebook.com/oreilly
Follow us on Twitter: http://twitter.com/oreillymedia
Watch us on YouTube: http://www.youtube.com/oreillymedia
Acknowledgments
I would like to once again thank my editor, Andy Oram, and
everyone who worked so hard on this book, including Albert Wiersch
for his comprehensive technical review, Kristen Brown for overseeing
production, Rachel Monaghan for her copyediting, Jasmine Kwityn
for proofreading, Robert Romano for his original illustrations,
Rebecca Demarest for her new illustrations, David Futato for interior
design, Lucie Haskins for creating the index, Karen Montgomery for
the original sugar glider front cover design, Randy Comer for the
latest book cover, and everyone else too numerous to name who
submitted errata and offered suggestions for this new edition.
Chapter 1. Introduction to
Dynamic Web Content
NOTE
It is necessary to start using some acronyms more or less right away. I
have tried to clearly explain them before proceeding. But don’t worry
too much about what they stand for or what these names mean,
because the details will all become clear as you read on.
5. The web server, having received the request, fetches the home
page from its hard disk.
6. With the home page now in memory, the web server notices
that it is a file incorporating PHP scripting and passes the page
to the PHP interpreter.
10. The PHP interpreter returns the results of the executed PHP
code, along with the results from the MySQL database, to the
web server.
11. The web server returns the page to the requesting client, which
displays it.
Although it’s helpful to be aware of this process so that you know
how the three elements work together, in practice you don’t really
need to concern yourself with these details, because they all happen
automatically.
HTML pages returned to the browser in each example may well
contain JavaScript, which will be interpreted locally by the client, and
which could initiate another request—the same way embedded
objects such as images would.
The Benefits of PHP, MySQL, JavaScript, CSS,
and HTML5
At the start of this chapter, I introduced the world of Web 1.0, but it
wasn’t long before the rush was on to create Web 1.1, with the
development of such browser enhancements as Java, JavaScript,
JScript (Microsoft’s slight variant of JavaScript), and ActiveX. On the
server side, progress was being made on the Common Gateway
Interface (CGI) using scripting languages such as Perl (an alternative
to the PHP language) and server-side scripting—inserting the
contents of one file (or the output of a system call) into another one
dynamically.
Once the dust had settled, three main technologies stood head and
shoulders above the others. Although Perl was still a popular
scripting language with a strong following, PHP’s simplicity and built-
in links to the MySQL database program had earned it more than
double the number of users. And JavaScript, which had become an
essential part of the equation for dynamically manipulating CSS
(Cascading Style Sheets) and HTML, now took on the even more
muscular task of handling the client side of the Ajax process. Under
Ajax, web pages perform data handling and send requests to web
servers in the background—without the web user being aware that
this is going on.
No doubt the symbiotic nature of PHP and MySQL helped propel
them both forward, but what attracted developers to them in the
first place? The simple answer has to be the ease with which you
can use them to quickly create dynamic elements on websites.
MySQL is a fast and powerful, yet easy-to-use, database system that
offers just about anything a website would need in order to find and
serve up data to browsers. When PHP allies with MySQL to store and
retrieve this data, you have the fundamental parts required for the
development of social networking sites and the beginnings of Web
2.0.
And when you bring JavaScript and CSS into the mix too, you have a
recipe for building highly dynamic and interactive websites.
Using PHP
With PHP, it’s a simple matter to embed dynamic activity in web
pages. When you give pages the .php extension, they have instant
access to the scripting language. From a developer’s point of view,
all you have to do is write code such as the following:
<?php
echo " Today is " . date("l") . ". ";
?>
The opening <?php tells the web server to allow the PHP program to
interpret all the following code up to the ?> tag. Outside of this
construct, everything is sent to the client as direct HTML. So the text
Here's the latest news. is simply output to the browser; within
the PHP tags, the built-in date function displays the current day of
the week according to the server’s system time.
The final output of the two parts looks like this:
PHP is a flexible language, and some people prefer to place the PHP
construct directly next to PHP code, like this:
NOTE
If you intend to enter the PHP examples in this book to work along with
me, you must remember to add <?php in front and ?> after them to
ensure that the PHP interpreter processes them. To facilitate this, you
may wish to prepare a file called example.php with those tags in place.
Using PHP, you have unlimited control over your web server.
Whether you need to modify HTML on the fly, process a credit card,
add user details to a database, or fetch information from a third-
party website, you can do it all from within the same PHP files in
which the HTML itself resides.
Using MySQL
Of course, there’s not much point to being able to change HTML
output dynamically unless you also have a means to track the
changes that users make as they use your website. In the early days
of the Web, many sites used “flat” text files to store data such as
usernames and passwords. But this approach could cause problems
if the file wasn’t correctly locked against corruption from multiple
simultaneous accesses. Also, a flat file can get only so big before it
becomes unwieldy to manage—not to mention the difficulty of trying
to merge files and perform complex searches in any kind of
reasonable time.
That’s where relational databases with structured querying become
essential. And MySQL, being free to use and installed on vast
numbers of Internet web servers, rises superbly to the occasion. It is
a robust and exceptionally fast database management system that
uses English-like commands.
The highest level of MySQL structure is a database, within which you
can have one or more tables that contain your data. For example,
let’s suppose you are working on a table called users, within which
you have created columns for surname, firstname, and email, and
you now wish to add another user. One command that you might
use to do this is:
MySQL will then return Smith, John and any other pairs of names
that may be associated with that email address in the database.
As you’d expect, there’s quite a bit more that you can do with
MySQL than just simple INSERT and SELECT commands. For example,
you can join multiple tables according to various criteria, ask for
results in a variety of orders, make partial matches when you know
only part of the string that you are searching for, return only the nth
result, and a lot more.
Using PHP, you can make all these calls directly to MySQL without
having to run the MySQL program yourself or use its command-line
interface. This means you can save the results in arrays for
processing and perform multiple lookups, each dependent on the
results returned from earlier ones, to drill right down to the item of
data you need.
For even more power, as you’ll see later, there are additional
functions built right into MySQL that you can call up for common
operations and extra speed.
Using JavaScript
The oldest of the three core technologies in this book, JavaScript,
was created to enable scripting access to all the elements of an
HTML document. In other words, it provides a means for dynamic
user interaction such as checking email address validity in input
forms, displaying prompts such as “Did you really mean that?”, and
so on (note, however, that it cannot be relied upon for security,
which should always be performed on the web server).
Combined with CSS (see the following section), JavaScript is the
power behind dynamic web pages that change in front of your eyes
rather than when a new page is returned by the server.
However, JavaScript can also be tricky to use, due to some major
differences in the ways different browser designers have chosen to
implement it. This mainly came about when some manufacturers
tried to put additional functionality into their browsers at the
expense of compatibility with their rivals.
Thankfully, the developers have mostly now come to their senses
and have realized the need for full compatibility with one another, so
they don’t have to write multi-exception code. But there remain
millions of legacy browsers that will be in use for a good many years
to come. Luckily, there are solutions for the incompatibility problems,
and later in this book we’ll look at libraries and techniques that
enable you to safely ignore these differences.
For now, let’s take a quick look at how you can use basic JavaScript,
accepted by all browsers:
<script type="text/javascript">
document.write("Today is " + Date() );
</script>
NOTE
Unless you need to specify an exact version of JavaScript, you can
normally omit the type="text/javascript" and just use <script> to
start the interpretation of the JavaScript.
Using CSS
With the emergence of the CSS3 standard in recent years, CSS now
offers a level of dynamic interactivity previously supported only by
JavaScript. For example, not only can you style any HTML element to
change its dimensions, colors, borders, spacing, and so on, but now
you can also add animated transitions and transformations to your
web pages, using only a few lines of CSS.
Using CSS can be as simple as inserting a few rules between
<style> and </style> tags in the head of a web page, like this:
<style>
p {
text-align:justify;
font-family:Helvetica;
}
</style>
These rules will change the default text alignment of the <p> tag so
that paragraphs contained in it will be fully justified and will use the
Helvetica font.
As you’ll learn in Chapter 19, there are many different ways you can
lay out CSS rules, and you can also include them directly within tags
or save a set of rules to an external file to be loaded in separately.
This flexibility not only lets you style your HTML precisely, but it can
also, for example, provide built-in hover functionality to animate
objects as the mouse passes over them. You will also learn how to
access all of an element’s CSS properties from JavaScript as well as
HTML.
And Then There’s HTML5
As useful as all these additions to the web standards became, they
were not enough for ever more ambitious developers. For example,
there was still no simple way to manipulate graphics in a web
browser without resorting to plug-ins such as Flash. And the same
went for inserting audio and video into web pages. Plus, several
annoying inconsistencies had crept into HTML during its evolution.
So, to clear all this up and take the Internet beyond Web 2.0 and
into its next iteration, a new standard for HTML was created to
address all these shortcomings. It was called HTML5 and it began
development as long ago as 2004, when the first draft was drawn up
by the Mozilla Foundation and Opera Software (developers of two
popular web browsers). But it wasn’t until the start of 2013 that the
final draft was submitted to the World Wide Web Consortium (W3C),
the international governing body for web standards.
With nine years for it to develop, you might think that would be the
end of the specification, but that’s not how things work on the
Internet. Although websites come and go at great speed, the
underlying software is developed slowly and carefully, and so the
stable recommendation for HTML5 is not expected until after this
edition of the book has been published—in late 2014. And then
guess what? Work will move on to versions 5.1 and higher,
beginning in 2015. It’s a never-ending cycle of development.
However, while HTML5.1 is planned to bring some handy
improvements (mainly to the canvas), basic HTML5 is the new
standard web developers now need to work to, and it will remain in
place for many years to come. So learning everything you can about
it now will stand you in very good stead.
There’s actually a great deal of new stuff in HTML (and quite a few
things that have been changed or removed), but in summary, here’s
what you get:
Markup
Including new elements such as <nav> and <footer>, and
deprecated elements like <font> and <center>.
New APIs
For example, the <canvas> element for writing and drawing on a
graphics canvas, <audio> and <video> elements, offline web
apps, microdata, and local storage.
Applications
Including two new rendering technologies: MathML (Math
Markup Language) for displaying mathematical formulae) and
SVG (Scalable Vector Graphics) for creating graphical elements
outside of the new <canvas> element. However, MathML and SVG
are somewhat specialist, and are so feature-packed they would
need a book of their own, so I don’t cover them here.
All these things (and more) are covered in detail starting in
Chapter 22.
NOTE
One of the little things I like about the HTML5 specification is that
XHTML syntax is no longer required for self-closing elements. In the
past you could display a line break using the <br> element. Then, to
ensure future compatibility with XHTML (the planned replacement for
HTML that never happened), this was changed to <br />, in which a
closing / character was added (because all elements were expected to
include a closing tag featuring this character). But now things have
gone full circle, and you can use either version of these element types.
So, for the sake of brevity and fewer keystrokes, in this book I have
reverted to the former style of <br>, <hr>, and so on.
The Apache Web Server
In addition to PHP, MySQL, JavaScript, CSS, and HTML5, there’s
actually a sixth hero in the dynamic Web: the web server. In the
case of this book, that means the Apache web server. We’ve
discussed a little of what a web server does during the HTTP
server/client exchange, but it actually does much more behind the
scenes.
For example, Apache doesn’t serve up just HTML files—it handles a
wide range of files from images and Flash files to MP3 audio files,
RSS (Really Simple Syndication) feeds, and so on. To do this, each
element a web client encounters in an HTML page is also requested
from the server, which then serves it up.
But these objects don’t have to be static files such as GIF images.
They can all be generated by programs such as PHP scripts. That’s
right: PHP can even create images and other files for you, either on
the fly or in advance to serve up later.
To do this, you normally have modules either precompiled into
Apache or PHP or called up at runtime. One such module is the GD
(Graphics Draw) library, which PHP uses to create and handle
graphics.
Apache also supports a huge range of modules of its own. In
addition to the PHP module, the most important for your purposes
as a web programmer are the modules that handle security. Other
examples are the Rewrite module, which enables the web server to
handle a varying range of URL types and rewrite them to its own
internal requirements, and the Proxy module, which you can use to
serve up often-requested pages from a cache to ease the load on
the server.
Later in the book, you’ll see how to actually use some of these
modules to enhance the features provided by the three core
technologies.
About Open Source
Whether the open source quality of these technologies is the reason
they are so popular has often been debated, but PHP, MySQL, and
Apache are the three most commonly used tools in their categories.
What can be said definitively, though, is that their being open source
means that they have been developed in the community by teams of
programmers writing the features they themselves want and need,
with the original code available for all to see and change. Bugs can
be found and security breaches can be prevented before they
happen.
There’s another benefit: all these programs are free to use. There’s
no worrying about having to purchase additional licenses if you have
to scale up your website and add more servers. And you don’t need
to check the budget before deciding whether to upgrade to the
latest versions of these products.
3. Once the text has been entered and the field deselected, in the
background the JavaScript code passes the username that was
entered back to a PHP script on the web server and awaits a
response.
4. The web server looks up the username and replies back to the
JavaScript regarding whether that name has already been
taken.
6. If the username is not available and the user still submits the
form, the JavaScript interrupts the submission and
reemphasizes (perhaps with a larger graphic and/or an alert
box) that the user needs to choose another username.
If you wish to develop Internet applications but don’t have your own
development server, you will have to upload every modification you
make to a server somewhere else on the Web before you can test it.
Even on a fast broadband connection, this can still represent a
significant slowdown in development time. On a local computer,
however, testing can be as easy as saving an update (usually just a
matter of clicking once on an icon) and then hitting the Refresh button
in your browser.
Another advantage of a development server is that you don’t have to
worry about embarrassing errors or security problems while you’re
writing and testing, whereas you need to be aware of what people
may see or do with your application when it’s on a public website. It’s
best to iron everything out while you’re still on a home or small office
system, presumably protected by firewalls and other safeguards.
Once you have your own development server, you’ll wonder how you
ever managed without one, and it’s easy to set one up. Just follow the
steps in the following sections, using the appropriate instructions for a
PC, a Mac, or a Linux system.
In this chapter, we cover just the server side of the web experience,
as described in Chapter 1. But to test the results of your work—
particularly when we start using JavaScript, CSS, and HTML5 later in
this book—you should also have an instance of every major web
browser running on some system convenient to you. Whenever
possible, the list of browsers should include at least Internet Explorer,
Mozilla Firefox, Opera, Safari, and Google Chrome.
If you plan to ensure your sites look good on mobile devices too, then
you should also try to arrange access to a wide range of Apple iOS
and Google Android phones and tablets.
WARNING
If you choose not to go the WAMP/MAMP/LAMP route for building your
own development system, you should know that downloading and
integrating the various parts yourself can be very time-consuming and
may require a lot of research in order to configure everything fully. But if
you already have all the components installed and integrated with one
another, they should work with the examples in this book.
Installing a WAMP on Windows
There are several available WAMP servers, each offering slightly
different configurations, but the best is probably Zend Server Free
Edition, because it’s free and is from the developers of PHP itself. You
can download it at http://tinyurl.com/zendfree, as shown in Figure 2-
1.
NOTE
Throughout this book, whenever there’s a long URL to type, I use the
TinyURL web address shortening service to save you time and reduce
typos. For example, the URLs http://tinyurl.com/zendfree and
http://tinyurl.com/zenddocs are much shorter than the URLs that they
lead to:
http://www.zend.com/en/products/server/free-edition
http://files.zend.com/help/Zend-Server-6/zend-server.htm
Figure 2-1. You can download the Free Edition from the Zend website
I recommend that you always download the latest stable release (in
this instance, it’s 6.3.0/PHP 5.5 for Windows). It will probably be listed
first in the Download section of the web page, which should display
the correct installer for your computer out of Linux, Windows OS X,
and IBM i.
NOTE
During the lifetime of this edition, some of the screens and options shown
in the following walkthrough may change. If so, just use your common
sense to proceed in as similar a manner as possible to the sequence of
actions described.
Click Next and accept the license agreement that follows to move on
to the Setup Type screen (see Figure 2-3), then select the Custom
option so that the MySQL server can also be installed.
Figure 2-3. Choose the Custom install option
When the Custom Setup window appears, scroll down the list of
options to the bottom and ensure that MySQL Server is checked, as
shown in Figure 2-4, then click Next.
Figure 2-4. Check MySQL Server before continuing
On the following screen (see Figure 2-5), even if you already have an
IIS web server installed, I recommend that you choose to install the
Apache web server, because the examples in this book are for Apache.
Then click Next.
Figure 2-5. Install the Apache web server
Now accept the default values of 80 for the Web Server Port, and
10081 for the Zend Server Interface Port (see Figure 2-6) and click
Next.
NOTE
If either of the ports offered states that it is occupied (generally this will
be because you have another web server running) and doesn’t allow you
to use the defaults, then try a value of 8080 (or 8000) for the Web Server
Port, and 10082 for the Zend Server Interface Port. You’ll need to
remember these values for later when you’re accessing either web pages
or the Zend server. For example, instead of visiting localhost/index.htm in
your web browser, you would use localhost:8080/index.htm.
Figure 2-6. Accept the default values offered for the ports
Once the ports have been assigned, you will reach the screen in
Figure 2-7, where you should click Install to start the installation.
Figure 2-7. Now you are ready to click Install to proceed
Next, you are asked how you will be using the server. I recommend
that you select the Development option for the purposes of working
through the exercises in this book (see Figure 2-9).
Figure 2-9. Select the Development option
Now you are ready to set a password for the user admin (see
Figure 2-10). You do not need to enter a password for the user
developer. Make sure you choose a password you will remember and
click Next. After the library packages show as deployed, click Next
again to proceed to the screen shown in Figure 2-11, where you can
now click Launch to finish installation. Note that the Cluster
Configuration option may not appear on the OS X version of the
installer.
Figure 2-10. Choose your password and enter it twice
Figure 2-11. Click Submit to complete setup
After a short wait, your browser will show the Dashboard screen in
Figure 2-12, which is where you can administer the server.
Figure 2-12. The Zend Server administration screen
localhost
127.0.0.1
Figure 2-13. How the home page should look by default
The document root is the directory that contains the main web
documents for a domain. This is the one that is entered when a basic
URL without a path is typed into a browser, such as http://yahoo.com
or, for your local server, http://localhost.
By default, Zend Server uses one of the following locations for this
directory (the former for 32-bit computers, and the latter for 64-bit):
C:/Program Files/Zend/Apache2/htdocs
C:/Program Files (x86)/Zend/Apache2/htdocs
NOTE
If you are not sure whether your computer is 32-bit or 64-bit, try to
navigate to the first directory and, if it exists, you have a 32-bit machine.
If not, open up the second directory because you have a 64-bit computer.
When they include spaces, older versions of Windows may require you to
place path and filenames in quotation marks, like this:
cd "C:/Program Files/Zend/Apache2/htdocs"
Once you have typed this, save the file into the document root
directory previously discussed, using the filename test.htm. If you are
using Notepad, make sure that the “Save as type” box is changed
from “Text Documents (*.txt)” to “All Files (*.*)”. Or, if you prefer, you
can save the file using the .html file extension; either is acceptable.
You can now call this page up in your browser by entering one of the
following URLs (according to the extension you used) in its address
bar (see Figure 2-14):
http://localhost/test.htm
http://localhost/test.html
XAMPP
WAMPServer
Glossword WAMP
Punishment varies in cruelty and intensity with the crime; for the
murder of a father, mother, or several people of one family the
sentence is “ignominious and slow death.” This method is known as
ling che, and the victim is attached to a post and cut to pieces by
slow degrees, the pieces being thrown about among the crowd. This
cruel death was more than once publicly inflicted in Peking during
the year 1903. Some of the most horrible passages in the Peking
Gazette are those which announce the infliction of this awful
punishment on madmen and idiots who in sudden outbreaks of
mania have committed parricide. For this offence no infirmity is
accepted, even as a palliation. A culprit condemned to ling che is
tied to a cross, and while he is yet alive gashes are made by the
executioner on the fleshy parts of his body, varying in number
according to the disposition of the judge. When this part of the
sentence has been carried out, a merciful blow severs the head from
the body. It is said that the executioner can be bribed to put
sufficient opium into the victim’s last meal to make him practically
unconscious, or even to inflict the fatal stab in the heart at first,
which should ordinarily be the last. Common cases of capital
punishment are comparatively merciful, for the executioners are so
skilful that they generally sever the head from the trunk with one
swift blow. The Chinese prefer death by strangulation to any other
form, because it enables the body to appear unmutilated in the next
world. This feeling has such a hold on them that when four victims
were decapitated in Peking, their relatives instantly claimed the
bodies and sewed on the heads. The permission to do this was
regarded by them as a great privilege and a mitigation of the
sentence.
Besides the prison in which convicts are confined there is also within
the precincts of the yamun a house of detention. This is neither so
large nor so strongly enclosed as the common gaol. Generally, in
such a house of detention there is a large chamber which is set
apart for the reception of prisoners on remand, who have friends
able and willing to satisfy the demands of the governor. By this
arrangement such prisoners avoid the misery of being shut up in the
same ward with men of the vilest character and often most
loathsome condition, covered with filth or suffering from various
kinds of cutaneous diseases. The arrangement is a great advantage
to the governor of the gaol and to all prisoners who can afford to
pay for it, but a great disadvantage to other inmates. The space
required for the convenience of prisoners who have friends to look
after their wants leaves very little room indeed for the reception of
the great majority of the poorer criminals, who are huddled together
in a common ward sometimes too crowded to allow its occupants to
lie down. In the city of Canton, on the streets adjoining the yamuns,
there are other houses of detention, all densely crowded.
Imprisonment is not the only penalty inflicted; cases of petty larceny
are generally dealt with by flogging. The culprit is handcuffed and
with the identical article which he stole, or one similar, suspended
from his neck, is marched through the streets of the neighbourhood
in which the theft was committed. He is preceded by a man beating
a gong, and at each beat of the gong an officer who walks behind
gives him a severe blow with a double rattan across the shoulders,
exclaiming, “This is the punishment due to a thief.” As the culprit has
to pass through three or four streets his punishment, although
regarded by the Chinese as a minor one, is certainly not lacking in
severity, and is often accompanied by a considerable flow of blood.
A thief who had stolen a watch from one of his countrymen was
flogged through the Honam suburb of Canton, but the officer
appointed to flog him was very corpulent, and from his great
earnestness in the discharge of his duty became quite breathless
before the various streets along which the culprit was sentenced to
pass had been fully traversed. The person from whom the watch had
been stolen, seeing that the thief might escape the full severity of
his penalty, snatched the double rattan from the hand of the
exhausted officer and applied it himself most unmercifully to the
thief’s back. Women who are convicted of thieving are in some
instances punished in this way. Occasionally a long bamboo is used
in cases of petty larceny. When this is the case, however, the culprit
receives his flogging in court in front of the tribunal. He is at once
denuded of his trousers and the number of blows varies according to
the nature of the larceny, from ten to three hundred.
Chinese Punishment
“For days he tracked him about the town, waiting for a favourable
opportunity. At last it came, as his rival passed him in the deep
embrasure of the Chien-men gate. Springing from his place of
concealment he challenged him to fight, but the coward refused.
Then Chiang-lo ... drew his knife and repeatedly stabbed him in the
heart. When he saw his enemy lying dead at his feet, the apathy of
despair fell upon him. Wiping his knife on his sleeve he bowed his
head, and turning his steps to the nearest police station calmly gave
himself up. A few weeks later he was beheaded.”
Tokio has now two prisons; the first and chief is situated upon the
island of Oshikawa at the south of the city, and the second, the
convict and female prison of Ichigawa, is in the centre of the city.
The former is completely isolated, all communication with the
mainland being by police ferry, and can accommodate two thousand
men and boys, who are serving terms of ten years or less. The
prison of Ichigawa usually contains fifteen hundred men and about
one hundred women, among whom are many serving life sentences.
Attached to the prison is a convict farm, and it is here that capital
punishment is carried out. Otherwise the two prisons resemble each
other closely and a description of one will answer for both, says Mr.
Norman, who described them in 1892, and gives the following
account:
ebookball.com