100% found this document useful (5 votes)
617 views62 pages

Instant Ebooks Textbook Learning PHP, MySQL & JavaScript, 6th Edition Robin Nixon Download All Chapters

MySQL

Uploaded by

jeejaskuse
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
100% found this document useful (5 votes)
617 views62 pages

Instant Ebooks Textbook Learning PHP, MySQL & JavaScript, 6th Edition Robin Nixon Download All Chapters

MySQL

Uploaded by

jeejaskuse
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 62

Download the full version of the textbook now at textbookfull.

com

Learning PHP, MySQL & JavaScript, 6th Edition


Robin Nixon

https://textbookfull.com/product/learning-php-
mysql-javascript-6th-edition-robin-nixon/

Explore and download more textbook at https://textbookfull.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Learning PHP MySQL JavaScript Early Release 6th Edition


Robin Nixon

https://textbookfull.com/product/learning-php-mysql-javascript-early-
release-6th-edition-robin-nixon/

textbookfull.com

Learning PHP MySQL JavaScript With jQuery CSS HTML5 5th


Edition Robin Nixon

https://textbookfull.com/product/learning-php-mysql-javascript-with-
jquery-css-html5-5th-edition-robin-nixon/

textbookfull.com

Biota Grow 2C gather 2C cook Loucas

https://textbookfull.com/product/biota-grow-2c-gather-2c-cook-loucas/

textbookfull.com

Energy Transitions and Social Psychology A Sociotechnical


Perspective 1st Edition Paul Upham

https://textbookfull.com/product/energy-transitions-and-social-
psychology-a-sociotechnical-perspective-1st-edition-paul-upham/

textbookfull.com
We the People Essentials Twelfth Edition Andrea Campbell
& Benjamin Ginsberg & Theodore J. Lowi & Robert J. Spitzer
& Caroline J. Tolbert & Margaret Weir
https://textbookfull.com/product/we-the-people-essentials-twelfth-
edition-andrea-campbell-benjamin-ginsberg-theodore-j-lowi-robert-j-
spitzer-caroline-j-tolbert-margaret-weir/
textbookfull.com

Molecular Pathology in Clinical Practice 2nd Edition Debra


G.B. Leonard (Eds.)

https://textbookfull.com/product/molecular-pathology-in-clinical-
practice-2nd-edition-debra-g-b-leonard-eds/

textbookfull.com

Fire fundamentals and control First Edition Haessler

https://textbookfull.com/product/fire-fundamentals-and-control-first-
edition-haessler/

textbookfull.com

Adorno’s Aesthetics as a Literary Theory of Art Mario


Farina

https://textbookfull.com/product/adornos-aesthetics-as-a-literary-
theory-of-art-mario-farina/

textbookfull.com

Algorithmic Aspects of Cloud Computing Third International


Workshop ALGOCLOUD 2017 Vienna Austria September 5 2017
Revised Selected Papers 1st Edition Dan Alistarh
https://textbookfull.com/product/algorithmic-aspects-of-cloud-
computing-third-international-workshop-algocloud-2017-vienna-austria-
september-5-2017-revised-selected-papers-1st-edition-dan-alistarh/
textbookfull.com
Roommates Life in the Brohouse 2 1st Edition Carmen Black

https://textbookfull.com/product/roommates-life-in-the-brohouse-2-1st-
edition-carmen-black/

textbookfull.com
Learning PHP, MySQL &
JavaScript
SIXTH EDITION

With Early Release ebooks, you get books in their earliest form—
the author’s raw and unedited content as they write—so you can
take advantage of these technologies long before the official
release of these titles.

With PHP 8, MySQL 8, PDO, CSS, HTML5, jQuery &


React

Robin Nixon
Learning PHP, MySQL & JavaScript
by Robin Nixon
Copyright © 2021 Robin Nixon. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North,
Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales
promotional use. Online editions are also available for most titles
(http://oreilly.com). For more information, contact our
corporate/institutional sales department: 800-998-9938 or
corporate@oreilly.com.

Editor: Rachel Roumeliotis

Production Editor: Caitlin Ghegan

Copyeditor: TK

Proofreader: TK

Indexer: TK

Interior Designer: David Futato

Cover Designer: Karen Montgomery

Illustrator: Catherine Dullea

July 2009: First Edition


August 2012: Second Edition
June 2014: Third Edition
December 2014: Fourth Edition
May 2018: Fifth Edition
November 2021
Revision History for the Early Release
2021-02-04: First release
See http://oreilly.com/catalog/errata.csp?isbn=9781492093817 for
release details.
The O’Reilly logo is a registered trademark of O’Reilly Media, Inc.
Learning PHP, MySQL & JavaScript, the cover image, and related
trade dress are trademarks of O’Reilly Media, Inc.
While the publisher and the author have used good faith efforts to
ensure that the information and instructions contained in this work
are accurate, the publisher and the author disclaim all responsibility
for errors or omissions, including without limitation responsibility for
damages resulting from the use of or reliance on this work. Use of
the information and instructions contained in this work is at your
own risk. If any code samples or other technology this work contains
or describes is subject to open source licenses or the intellectual
property rights of others, it is your responsibility to ensure that your
use thereof complies with such licenses and/or rights.
978-1-492-09381-7
[LSI]
Preface

The combination of PHP and MySQL is the most convenient


approach to dynamic, database-driven web design, holding its own
in the face of challenges from integrated frameworks—such as Ruby
on Rails—that are harder to learn. Due to its open source roots
(unlike the competing Microsoft .NET Framework), it is free to
implement and is therefore an extremely popular option for web
development.
Any would-be developer on a Unix/Linux or even a Windows/Apache
platform will need to master these technologies. And, combined with
the partner technologies of JavaScript, React, CSS, and HTML5, you
will be able to create websites of the caliber of industry standards
like Facebook, Twitter, and Gmail.

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 responsive
web design will obtain a thorough grounding in the core
technologies of PHP, MySQL, JavaScript, CSS, and HTML5, and you’ll
learn the basics of the React library and React Native Framework,
too.
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.

Organization of This Book


The chapters in this book are written in a specific order, first
introducing all of the core technologies it covers and then walking
you through their installation on a web development server so that
you will be ready to work through the examples.
In the first section, you will gain a grounding in the PHP
programming language, covering the basics of syntax, arrays,
functions, and object-oriented programming.
Then, with PHP under your belt, you will move on to an introduction
to the MySQL database system, where you will learn everything from
how MySQL databases are structured to how to generate complex
queries.
After that, you will learn how you can combine PHP and MySQL to
start creating your own dynamic web pages by integrating forms and
other HTML features. You will then get down to the nitty-gritty
practical aspects of PHP and MySQL development by learning a
variety of useful functions and how to manage cookies and sessions,
as well as how to maintain a high level of security.
In the next few chapters, you will gain a thorough grounding in
JavaScript, from simple functions and event handling to accessing
the Document Object Model, in-browser validation, and error
handling. You’ll also get a comprehensive primer on using the
popular React library for JavaScript.
With an understanding of all three of these core technologies, you
will then learn how to make behind-the-scenes Ajax calls and turn
your websites into highly dynamic environments.
Next, you’ll spend two chapters learning all about using CSS to style
and lay out your web pages, before discovering how the React
libraries can make your development job a great deal easier. You’ll
then move on to the final section on the interactive features built
into HTML5, including geolocation, audio, video, and the canvas.
After this, you’ll put together everything you’ve learned in a
complete set of programs that together constitute a fully functional
social networking website.
Along the way, you’ll find plenty of advice on good programming
practices and tips that can help you find and solve hard-to-detect
programming errors. There are also plenty of links to websites
containing further details on the topics covered.

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:
Dynamic HTML: The Definitive Reference by Danny
Goodman
PHP in a Nutshell by Paul Hudson
MySQL in a Nutshell by Russell Dyer
JavaScript: The Definitive Guide by David Flanagan
CSS: The Definitive Guide by Eric A. Meyer and Estelle Weyl
HTML5: The Missing Manual by Matthew MacDonald

Conventions Used in This Book


The following typographical conventions are used in this book:
Plain text
Indicates menu titles, options, and buttons.

Italic
Indicates new terms, URLs, email addresses, filenames, file
extensions, pathnames, directories, and Unix utilities. Also used
for database, table, and column names.

Constant width

Indicates commands and command-line options, variables and


other code elements, HTML tags, and the contents of files.

Constant width bold

Shows program output and is used to highlight sections of code


that are discussed in the text.

Constant width italic

Shows text that should be replaced with user-supplied values.

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
for download at github.com/RobinNixon/lpmj6.
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 set 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 6th Edition by Robin Nixon
(O’Reilly). Copyright 2021 Robin Nixon, [[[ISBN NUMBER GOES
HERE]]].”
If you feel your use of code examples falls outside fair use or the
permission given above, feel free to contact us at
permissions@oreilly.com.
O’Reilly Online Learning

NOTE
For more than 40 years, O’Reilly Media has provided technology and
business training, knowledge, and insight to help companies succeed.

Our unique network of experts and innovators share their knowledge


and expertise through books, articles, and our online learning
platform. O’Reilly’s online learning platform gives you on-demand
access to live training courses, in-depth learning paths, interactive
coding environments, and a vast collection of text and video from
O’Reilly and 200+ other publishers. For more information, visit
http://oreilly.com.

How to Contact Us
Please address comments and questions concerning this book to the
publisher:

O’Reilly Media, Inc.

1005 Gravenstein Highway North

Sebastopol, CA 95472

(800) 998-9938 (in the United States or Canada)

(707) 829-0515 (international or local)

(707) 829-0104 (fax)

We have a web page for this book, where we list errata, examples,
and any additional information. You can access this page at
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
[[[ERRATA URL GOES HERE]]].
To comment or ask technical questions about this book, send email
to bookquestions@oreilly.com.
For news and more information about our books and courses, 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 thank Senior Content Acquisitions Editor, Amanda
Quinn, Content Development Editor, Melissa Potter, and everyone
who worked so hard on this book, including ???, ??? & ??? for their
comprehensive technical reviews, ??? for overseeing production, ???
for copy editing, ??? for proofreading, ??? for creating the index,
Karen Montgomery for the original sugar glider front cover design,
??? for the latest book cover, my original editor, Andy Oram, for
overseeing the first five editions, and everyone else too numerous to
name who submitted errata and offered suggestions for this new
edition.
Chapter 1. Introduction to
Dynamic Web Content

The World Wide Web is a constantly evolving network that has


already traveled far beyond its conception in the early 1990s, when
it was created to solve a specific problem. State-of-the-art
experiments at CERN (the European Laboratory for Particle Physics,
now best known as the operator of the Large Hadron Collider) were
producing incredible amounts of data—so much that the data was
proving unwieldy to distribute to the participating scientists, who
were spread out across the world.
At this time, the internet was already in place, connecting several
hundred thousand computers, so Tim Berners-Lee (a CERN fellow)
devised a method of navigating between them using a hyperlinking
framework, which came to be known as Hypertext Transfer Protocol,
or HTTP. He also created a markup language called Hypertext
Markup Language, or HTML. To bring these together, he wrote the
first web browser and web server.
Today we take these tools for granted, but back then, the concept
was revolutionary. The most connectivity so far experienced by at-
home modem users was dialing up and connecting to a bulletin
board that was hosted by a single computer, where you could
communicate and swap data only with other users of that service.
Consequently, you needed to be a member of many bulletin board
systems in order to effectively communicate electronically with your
colleagues and friends.
But Berners-Lee changed all that in one fell swoop, and by the mid-
1990s, there were three major graphical web browsers competing
for the attention of 5 million users. It soon became obvious, though,
that something was missing. Yes, pages of text and graphics with
hyperlinks to take you to other pages was a brilliant concept, but the
results didn’t reflect the instantaneous potential of computers and
the internet to meet the particular needs of each user with
dynamically changing content. Using the web was a very dry and
plain experience, even if we did now have scrolling text and
animated GIFs!
Shopping carts, search engines, and social networks have clearly
altered how we use the web. In this chapter, we’ll take a brief look
at the various components that make up the web, and the software
that helps make using it a rich and dynamic experience.

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 become clear as you read on.

HTTP and HTML: Berners-Lee’s Basics


HTTP is a communication standard governing the requests and
responses that are sent between the browser running on the end
user’s computer and the web server. The server’s job is to accept a
request from the client and attempt to reply to it in a meaningful
way, usually by serving up a requested web page—that’s why the
term server is used. The natural counterpart to a server is a client,
so that term is applied both to the web browser and the computer
on which it’s running.
Between the client and the server there can be several other
devices, such as routers, proxies, gateways, and so on. They serve
different roles in ensuring that the requests and responses are
correctly transferred between the client and server. Typically, they
use the internet to send this information. Some of these in-between
devices can also help speed up the internet by storing pages or
information locally in what is called a cache, and then serving this
content up to clients directly from the cache rather than fetching it
all the way from the source server.
A web server can usually handle multiple simultaneous connections,
and when not communicating with a client, it spends its time
listening for an incoming connection. When one arrives, the server
sends back a response to confirm its receipt.

The Request/Response Procedure


At its most basic level, the request/response process consists of a
web browser asking the web server to send it a web page and the
server sending back the page. The browser then takes care of
displaying the page (see Figure 1-1).
Figure 1-1. The basic client/server request/response sequence

The steps in the request and response sequence are as follows:


1. You enter http://server.com into your browser’s address bar.
2. Your browser looks up the Internet Protocol (IP) address for
server.com.
3. Your browser issues a request for the home page at
server.com.
4. The request crosses the internet and arrives at the
server.com web server.
5. The web server, having received the request, looks for the
web page on its disk.
6. The web server retrieves the page and returns it to the
browser.
7. Your browser displays the web page.
For an average web page, this process also takes place once for
each object within the page: a graphic, an embedded video or Flash
file, and even a CSS template.
In step 2, notice that the browser looks up the IP address of
server.com. Every machine attached to the internet has an IP
address—your computer included—but we generally access web
servers by name, such as google.com. As you probably know, the
browser consults an additional internet service called the Domain
Name Service (DNS) to find the server’s associated IP address and
then uses it to communicate with the computer.
For dynamic web pages, the procedure is a little more involved,
because it may bring both PHP and MySQL into the mix. For
instance, you may click on a picture of a raincoat. Then PHP will put
together a request using the standard database language, SQL—
many of whose commands you will learn in this book—and send the
request to the MySQL server. The MySQL server will return
information about the raincoat you selected, and the PHP code will
wrap it all up in some HTML, which the server will send to your
browser (see Figure 1-2).
Figure 1-2. A dynamic client/server request/response sequence

The steps are as follows:

1. You enter http://server.com into your browser’s address bar.


2. Your browser looks up the IP address for server.com.
3. Your browser issues a request to that address for the web
server’s home page.
4. The request crosses the internet and arrives at the
server.com web server.
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.
7. The PHP interpreter executes the PHP code.
8. Some of the PHP contains SQL statements, which the PHP
interpreter now passes to the MySQL database engine.
9. The MySQL database returns the results of the statements 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.
The 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 running a local program) 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
Cascading Style Sheets (CSS) and HTML, now took on the even
more muscular task of handling the client side of the asynchronous
communication (exchanging data between a client and server after a
web page has loaded). Using asynchronous communication, 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
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
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—
especially as there is now a wide range of sophisticated frameworks
of JavaScript functions you can call on to really speed up web
development, such as the well-known jQuery, which until very
recently was one of the most common way programmers access
asynchronous communication features, and the more recent React
JavaScript library which has been growing quickly in popularity, and
is now one of the most widely downloaded and implemented
frameworks, so much so that since 2020 the Indeed job site lists
more than twice as many positions for React developers than for
jQuery.

MariaDB: The MySQL Clone


After Oracle purchased Sun Microsystems (the owners of MySQL),
the community became wary that MySQL might not remain fully
open source, so MariaDB was forked from it to keep it free under the
GNU GPL. Development of MariaDB is led by some of the original
developers of MySQL and it retains exceedingly close compatibility
with MySQL. Therefore, you may well encounter MariaDB on some
servers in place of MySQL—but not to worry, everything in this book
works equally well on both MySQL and MariaDB, which is based on
the same code base as MySQL Server 5.5. To all intents and
purposes you can swap one with the other and notice no difference.
Anyway, as it turns out, many of the initial fears appear to have
been allayed as MySQL remains open source, with Oracle simply
charging for support and for editions that provide additional features
such as geo-replication and automatic scaling. However, unlike
MariaDB, MySQL is no longer community driven, so knowing that
MariaDB will always be there if ever needed will keep many
developers sleeping at night, and probably ensures that MySQL itself
will remain open source.

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") . ". ";
?>

Here's the latest news.

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:

Today is Wednesday. Here's the latest news.


PHP is a flexible language, and some people prefer to place the PHP
construct directly next to PHP code, like this:

Today is <?php echo date("l"); ?>. Here's the latest news.

There are even more ways of formatting and outputting information,


which I’ll explain in the chapters on PHP. The point is that with PHP,
web developers have a scripting language that, although not as fast
as compiling your code in C or a similar language, is incredibly
speedy and also integrates seamlessly with HTML markup.

NOTE
If you intend to enter the PHP examples in this book into a program
editor 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 a lot of point to being able to change HTML
output dynamically unless you also have a means to track the
information users provide to your website as they use it. 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 as follows:

INSERT INTO users VALUES('Smith', 'John',


'jsmith@mysite.com');

You will previously have issued other commands to create the


database and table and to set up all the correct fields, but the SQL
INSERT command here shows how simple it can be to add new data
to a database. SQL is a language designed in the early 1970s that is
reminiscent of one of the oldest programming languages, COBOL. It
is well suited, however, to database queries, which is why it is still in
use after all this time.
It’s equally easy to look up data. Let’s assume that you have an
email address for a user and need to look up that person’s name. To
do this, you could issue a MySQL query such as the following:

SELECT surname,firstname FROM users WHERE


email='jsmith@mysite.com';
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 combine related data sets to bring related pieces
of information together, 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 directly access the MySQL command-line interface
yourself. 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 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 to efficiently run
common operations within MySQL, rather than creating them out of
multiple PHP calls to MySQL.

Using JavaScript
The oldest of the three core technologies discussed 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 and displaying prompts such as “Did you really mean
that?” (although 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.
Random documents with unrelated
content Scribd suggests to you:
now seeking further light on the cause of gravitation; we are
interested in seeing what would really be involved in a complete
explanation of anything physical.
Einstein’s law in its analytical form is a statement that in empty
space certain quantities called potentials obey certain lengthy
differential equations. We make a memorandum of the word
“potential” to remind us that we must later on explain what it
means. We might conceive a world in which the potentials at every
moment and every place had quite arbitrary values. The actual world
is not so unlimited, the potentials being restricted to those values
which conform to Einstein’s equations. The next question is, What
are potentials? They can be defined as quantities derived by quite
simple mathematical calculations from certain fundamental
quantities called intervals. (MEM. Explain “interval”.) If we know the
values of the various intervals throughout the world definite rules
can be given for deriving the values of the potentials. What are
intervals? They are relations between pairs of events which can be
measured with a scale or a clock or with both. (MEM. Explain “scale”
and “clock”.) Instructions can be given for the correct use of the
scale and clock so that the interval is given by a prescribed
combination of their readings. What are scales and clocks? A scale is
a graduated strip of matter which.... (MEM. Explain “matter”.) On
second thoughts I will leave the rest of the description as “an
exercise to the reader” since it would take rather a long time to
enumerate all the properties and niceties of behaviour of the
material standard which a physicist would accept as a perfect scale
or a perfect clock. We pass on to the next question, What is matter?
We have dismissed the metaphysical conception of substance. We
might perhaps here describe the atomic and electrical structure of
matter, but that leads to the microscopic aspects of the world,
whereas we are here taking the macroscopic outlook. Confining
ourselves to mechanics, which is the subject in which the law of
gravitation arises, matter may be defined as the embodiment of
three related physical quantities, mass (or energy), momentum and
stress. What are “mass”, “momentum” and “stress”? It is one of the
most far-reaching achievements of Einstein’s theory that it has given
an exact answer to this question. They are rather formidable looking
expressions containing the potentials and their first and second
derivatives with respect to the co-ordinates. What are the potentials?
Why, that is just what I have been explaining to you!
The definitions of physics proceed according to the method
immortalised in “The House that Jack built”: This is the potential,
that was derived from the interval, that was measured by the scale,
that was made from the matter, that embodied the stress, that....
But instead of finishing with Jack, whom of course every youngster
must know without need for an introduction, we make a circuit back
to the beginning of the rhyme: ... that worried the cat, that killed the
rat, that ate the malt, that lay in the house, that was built by the
priest all shaven and shorn, that married the man.... Now we can go
round and round for ever.
But perhaps you have already cut short my explanation of
gravitation. When we reached matter you had had enough of it.
“Please do not explain any more, I happen to know what matter is.”
Very well; matter is something that Mr. X knows. Let us see how it
goes: This is the potential that was derived from the interval that
was measured by the scale that was made from the matter that Mr.
X knows. Next question, What is Mr. X?
Well, it happens that physics is not at all anxious to pursue the
question, What is Mr. X? It is not disposed to admit that its elaborate
structure of a physical universe is “The House that Mr. X built”.
Fig. 8
It looks upon Mr. X—and more particularly the part of Mr. X that
knows—as a rather troublesome tenant who at a late stage of the
world’s history has come to inhabit a structure which inorganic
Nature has by slow evolutionary progress contrived to build. And so
it turns aside from the avenue leading to Mr. X—and beyond—and
closes up its cycle leaving him out in the cold.
From its own point of view physics is entirely justified. That
matter in some indirect way comes within the purview of Mr. X’s
mind is not a fact of any utility for a theoretical scheme of physics.
We cannot embody it in a differential equation. It is ignored; and the
physical properties of matter and other entities are expressed by
their linkages in the cycle. And you can see how by the ingenious
device of the cycle physics secures for itself a self-contained domain
for study with no loose ends projecting into the unknown. All other
physical definitions have the same kind of interlocking. Electric force
is defined as something which causes motion of an electric charge;
an electric charge is something which exerts electric force. So that
an electric charge is something that exerts something that produces
motion of something that exerts something that produces ... ad
infinitum.
But I am not now writing of pure physics, and from a broader
standpoint I do not see how we can leave out Mr. X. The fact that
matter is “knowable to Mr. X” must be set down as one of the
fundamental attributes of matter. I do not say that it is very
distinctive, since other entities of physics are also knowable to him;
but the potentiality of the whole physical world for awaking
impressions in consciousness is an attribute not to be ignored when
we compare the actual world with worlds which, we fancy, might
have been created. There seems to be a prevalent disposition to
minimise the importance of this. The attitude is that “knowableness
to Mr. X” is a negligible attribute, because Mr. X is so clever that he
could know pretty much anything that there was to know. I have
already urged the contrary view—that there is a definitely selective
action of the mind; and since physics treats of what is knowable to
mind[43] its subject-matter has undergone, and indeed retains
evidences of, this process of selection.

Actuality. “Knowableness to mind” is moreover a property which


differentiates the actual world of our experience from imaginary
worlds in which the same general laws of Nature are supposed to
hold true. Consider a world—Utopia, let us say—governed by all the
laws of Nature known and unknown which govern our own world,
but containing better stars, planets, cities, animals, etc.—a world
which might exist, but it just happens that it doesn’t. How can the
physicist test that Utopia is not the actual world? We refer to a piece
of matter in it; it is not real matter but it attracts any other piece of
(unreal) matter in Utopia according to the law of gravitation. Scales
and clocks constructed of this unreal matter will measure wrong
intervals, but the physicist cannot detect that they are wrong unless
he has first shown the unreality of the matter. As soon as any
element in it has been shown to be unreal Utopia collapses; but so
long as we keep to the cycles of physics we can never find the
vulnerable point, for each element is correctly linked to the rest of
the cycle, all our laws of Nature expressed by the cycle being obeyed
in Utopia by hypothesis. The unreal stars emit unreal light which falls
on unreal retinas and ultimately reaches unreal brains. The next step
takes it outside the cycle and gives the opportunity of exposing "the
whole deception. Is the brain disturbance translated into
consciousness? That will test whether the brain is real or unreal.
There is no question about consciousness being real or not;
consciousness is self-knowing and the epithet real adds nothing to
that. Of the infinite number of worlds which are examples of what
might be possible under the laws of Nature, there is one which does
something more than fulfil those laws of Nature. This property,
which is evidently not definable with respect to any of the laws of
Nature, we describe as “actuality”—generally using the word as a
kind of halo of indefinite import. We have seen that the trend of
modern physics is to reject these indefinite attributions and to define
its terms according to the way in which we recognise the properties
when confronted by them. We recognise the actuality of a particular
world because it is that world alone with which consciousness
interacts. However much the theoretical physicist may dislike a
reference to consciousness, the experimental physicist uses freely
this touchstone of actuality. He would perhaps prefer to believe that
his instruments and observations are certified as actual by his
material sense organs; but the final guarantor is the mind that
comes to know the indications of the material organs. Each of us is
armed with this touchstone of actuality; by applying it we decide
that this sorry world of ours is actual and Utopia is a dream. As our
individual consciousnesses are different, so our touchstones are
different; but fortunately they all agree in their indication of actuality
—or at any rate those which agree are in sufficient majority to shut
the others up in lunatic asylums.
It is natural that theoretical physics in its formulation of a general
scheme of law should leave out of account actuality and the
guarantor of actuality. For it is just this omission which makes the
difference between a law of Nature and a particular sequence of
events. That which is possible (or not “too improbable”) is the
domain of natural science; that which is actual is the domain of
natural history. We need scarcely add that the contemplation in
natural science of a wider domain than the actual leads to a far
better understanding of the actual.
From a broader point of view than that of elaborating the
physical scheme of law we cannot treat the connection with mind as
merely an incident in a self-existent inorganic world. In saying that
the differentiation of the actual from the non-actual is only
expressible by reference to mind I do not mean to imply that a
universe without conscious mind would have no more status than
Utopia. But its property of actuality would be indefinable since the
one approach to a definition is cut off. The actuality of Nature is like
the beauty of Nature. We can scarcely describe the beauty of a
landscape as non-existent when there is no conscious being to
witness it; but it is through consciousness that we can attribute a
meaning to it. And so it is with the actuality of the world. If actuality
means “known to mind” then it is a purely subjective character of
the world; to make it objective we must substitute “knowable to
mind”. The less stress we lay on the accident of parts of the world
being known at the present era to particular minds, the more stress
we must lay on the potentiality of being known to mind as a
fundamental objective property of matter, giving it the status of
actuality whether individual consciousness is taking note of it or not.
In the diagram Mr. X has been linked to the cycle at a particular
point in deference to his supposed claim that he knows matter; but a
little reflection will show that the point of contact of mind with the
physical universe is not very definite. Mr. X knows a table; but the
point of contact with his mind is not in the material of the table.
Light waves are propagated from the table to the eye; chemical
changes occur in the retina; propagation of some kind occurs in the
optic nerves; atomic changes follow in the brain. Just where the final
leap into consciousness occurs is not clear. We do not know the last
stage of the message in the physical world before it became a
sensation in consciousness. This makes no difference. The physical
entities have a cyclic connection, and whatever intrinsic nature we
attribute to one of them runs as a background through the whole
cycle. It is not a question whether matter or electricity or potential is
the direct stimulus to the mind; in their physical aspects these are
equally represented as pointer readings or schedules of pointer
readings. According to our discussion of world building they are the
measures of structure arising from the comparability of certain
aspects of the basal relations—measures which by no means
exhaust the significance of those relations. I do not believe that the
activity of matter at a certain point of the brain stimulates an activity
of mind; my view is that in the activity of matter there is a metrical
description of certain aspects of the activity of mind. The activity of
the matter is our way of recognising a combination of the measures
of structure; the activity of the mind is our insight into the complex
of relations whose comparability gives the foundation of those
measures.

“What is Mr. X?” In the light of these considerations let us now see
what we can make of the question, What is Mr. X? I must undertake
the inquiry single-handed; I cannot avail myself of your collaboration
without first answering or assuming an answer to the equally
difficult question, What are you? Accordingly the whole inquiry must
take place in the domain of my own consciousness. I find there
certain data purporting to relate to this unknown X; and I can (by
using powers which respond to my volition) extend the data, i.e. I
can perform experiments on X. For example I can make a chemical
analysis. The immediate result of these experiments is the
occurrence of certain visual or olfactory sensations in my
consciousness. Clearly it is a long stride from these sensations to any
rational inference about Mr. X. For example, I learn that Mr. X has
carbon in his brain, but the immediate knowledge was of something
(not carbon) in my own mind. The reason why I, on becoming aware
of something in my mind, can proceed to assert knowledge of
something elsewhere, is because there is a systematic scheme of
inference which can be traced from the one item of knowledge to
the other. Leaving aside instinctive or commonsense inference—the
crude precursor of scientific inference—the inference follows a
linkage, which can only be described symbolically, extending from
the point in the symbolic world where I locate myself to the point
where I locate Mr. X.
One feature of this inference is that I never discover what carbon
really is. It remains a symbol. There is carbon in my own brain-mind;
but the self-knowledge of my mind does not reveal this to me. I can
only know that the symbol for carbon must be placed there by
following a route of inference through the external world similar to
that used in discovering it in Mr. X; and however closely associated
this carbon may be with my thinking powers, it is as a symbol
divorced from any thinking capacity that I learn of its existence.
Carbon is a symbol definable only in terms of the other symbols
belonging to the cyclic scheme of physics. What I have discovered is
that, in order that the symbols describing the physical world may
conform to the mathematical formulae which they are designed to
obey, it is necessary to place the symbol for carbon (amongst
others) in the locality of Mr. X. By similar means I can make an
exhaustive physical examination of Mr. X and discover the whole
array of symbols to be assigned to his locality.
Will this array of symbols give me the whole of Mr. X? There is
not the least reason to think so. The voice that comes to us over the
telephone wire is not the whole of what is at the end of the wire.
The scientific linkage is like the telephone wire; it can transmit just
what it is constructed to transmit and no more.
It will be seen that the line of communication has two aspects. It
is a chain of inference stretching from the symbols immediately
associated with the sensations in my mind to the symbols descriptive
of Mr. X; and it is a chain of stimuli in the external world starting
from Mr. X and reaching my brain. Ideally the steps of the inference
exactly reverse the steps of the physical transmission which brought
the information. (Naturally we make many short cuts in inference by
applying accumulated experience and knowledge.) Commonly we
think of it only in its second aspect as a physical transmission; but
because it is also a line of inference it is subject to limitations which
we should not necessarily expect a physical transmission to conform
to.
The system of inference employed in physical investigation
reduces to mathematical equations governing the symbols, and so
long as we adhere to this procedure we are limited to symbols of
arithmetical character appropriate to such mathematical equations.
[44] Thus there is no opportunity for acquiring by any physical
investigation a knowledge of Mr. X other than that which can be
expressed in numerical form so as to be passed through a
succession of mathematical equations.
Mathematics is the model of exact inference; and in physics we
have endeavoured to replace all cruder inference by this rigorous
type. Where we cannot complete the mathematical chain we confess
that we are wandering in the dark and are unable to assert real
knowledge. Small wonder then that physical science should have
evolved a conception of the world consisting of entities rigorously
bound to one another by mathematical equations forming a
deterministic scheme. This knowledge has all been inferred and it
was bound therefore to conform to the system of inference that was
used. The determinism of the physical laws simply reflects the
determinism of the method of inference. This soulless nature of the
scientific world need not worry those who are persuaded that the
main significances of our environment are of a more spiritual
character. Anyone who studied the method of inference employed by
the physicist could predict the general characteristics of the world
that he must necessarily find. What he could not have predicted is
the great success of the method—the submission of so large a
proportion of natural phenomena to be brought into the prejudged
scheme. But making all allowance for future progress in developing
the scheme, it seems to be flying in the face of obvious facts to
pretend that it is all comprehensive. Mr. X is one of the recalcitrants.
When sound-waves impinge on his ear he moves, not in accordance
with a mathematical equation involving the physical measure
numbers of the waves, but in accordance with the meaning that
those sound-waves are used to convey. To know what there is about
Mr. X which makes him behave in this strange way, we must look not
to a physical system of inference, but to that insight beneath the
symbols which in our own minds we possess. It is by this insight that
we can finally reach an answer to our question, What is Mr. X?
[41] A good illustration of such substitution is afforded by
astronomical observations of a certain double star with two
components of equal brightness. After an intermission of
observation the two components were inadvertently interchanged,
and the substitution was not detected until the increasing
discrepancy between the actual and predicted orbits was inquired
into.
[42] For example, we should most of us assume (hypothetically)
that the dynamical quality of the world referred to in chapter V is
characteristic of the whole background. Apparently it is not to be
found in the pointer readings, and our only insight into it is in the
feeling of “becoming” in our consciousness. “Becoming” like
“reasoning” is known to us only through its occurrence in our own
minds; but whereas it would be absurd to suppose that the latter
extends to inorganic aggregations of atoms, the former may be
(and commonly is) extended to the inorganic world, so that it is
not a matter of indifference whether the progress of the inorganic
world is viewed from past to future or from future to past.
[43] This is obviously true of all experimental physics, and must
be true of theoretical physics if it is (as it professes to be) based
on experiment.
[44] The solitary exception is, I believe, Dirac’s generalisation
which introduces -numbers (p. 210). There is as yet no approach
to a general system of inference on a non-numerical basis.
Chapter XIII
REALITY
The Real and the Concrete. One of our ancestors, taking arboreal
exercise in the forest, failed to reach the bough intended and his
hand closed on nothingness. The accident might well occasion
philosophical reflections on the distinctions of substance and void—
to say nothing of the phenomenon of gravity. However that may be,
his descendants down to this day have come to be endowed with an
immense respect for substance arising we know not how or why. So
far as familiar experience is concerned, substance occupies the
centre of the stage, rigged out with the attributes of form, colour,
hardness, etc., which appeal to our several senses. Behind it is a
subordinate background of space and time permeated by forces and
unconcrete agencies to minister to the star performer.
Our conception of substance is only vivid so long as we do not
face it. It begins to fade when we analyse it. We may dismiss many
of its supposed attributes which are evidently projections of our
sense-impressions outwards into the external world. Thus the colour
which is so vivid to us is in our minds and cannot be embodied in a
legitimate conception of the substantial object itself. But in any case
colour is no part of the essential nature of substance. Its supposed
nature is that which we try to call to mind by the word “concrete”,
which is perhaps an outward projection of our sense of touch. When
I try to abstract from the bough everything but its substance or
concreteness and concentrate on an effort to apprehend this, all
ideas elude me; but the effort brings with it an instinctive tightening
of the fingers—from which perhaps I might infer that my conception
of substance is not very different from my arboreal ancestor’s.
So strongly has substance held the place of leading actor on the
stage of experience that in common usage concrete and real are
almost synonymous. Ask any man who is not a philosopher or a
mystic to name something typically real; he is almost sure to choose
a concrete thing. Put the question to him whether Time is real; he
will probably decide with some hesitation that it must be classed as
real, but he has an inner feeling that the question is in some way
inappropriate and that he is being cross-examined unfairly.
In the scientific world the conception of substance is wholly
lacking, and that which most nearly replaces it, viz. electric charge,
is not exalted as star-performer above the other entities of physics.
For this reason the scientific world often shocks us by its appearance
of unreality. It offers nothing to satisfy our demand for the concrete.
How should it, when we cannot formulate that demand? I tried to
formulate it; but nothing resulted save a tightening of the fingers.
Science does not overlook the provision for tactual and muscular
sensation. In leading us away from the concrete, science is
reminding us that our contact with the real is more varied than was
apparent to the ape-mind, to whom the bough which supported him
typified the beginning and end of reality.
It is not solely the scientific world that will now occupy our
attention. In accordance with the last chapter we are taking a larger
view in which the cyclical schemes of physics are embraced with
much besides. But before venturing on this more risky ground I have
to emphasise one conclusion which is definitely scientific. The
modern scientific theories have broken away from the common
standpoint which identifies the real with the concrete. I think we
might go so far as to say that time is more typical of physical reality
than matter, because it is freer from those metaphysical associations
which physics disallows. It would not be fair, being given an inch, to
take an ell, and say that having gone so far physics may as well
admit at once that reality is spiritual. We must go more warily. But in
approaching such questions we are no longer tempted to take up
the attitude that everything which lacks concreteness is thereby self-
condemned.
The cleavage between the scientific and the extra-scientific
domain of experience is, I believe, not a cleavage between the
concrete and the transcendental but between the metrical and the
non-metrical. I am at one with the materialist in feeling a
repugnance towards any kind of pseudo-science of the extra-
scientific territory. Science is not to be condemned as narrow
because it refuses to deal with elements of experience which are
unadapted to its own highly organised method; nor can it be blamed
for looking superciliously on the comparative disorganisation of our
knowledge and methods of reasoning about the non-metrical part of
experience. But I think we have not been guilty of pseudo-science in
our attempt to show in the last two chapters how it comes about
that within the whole domain of experience a selected portion is
capable of that exact metrical representation which is requisite for
development by the scientific method.

Mind-Stuff. I will try to be as definite as I can as to the glimpse of


reality which we seem to have reached. Only I am well aware that in
committing myself to details I shall probably blunder. Even if the
right view has here been taken of the philosophical trend of modern
science, it is premature to suggest a cut-and-dried scheme of the
nature of things. If the criticism is made that certain aspects are
touched on which come more within the province of the expert
psychologist, I must admit its pertinence. The recent tendencies of
science do, I believe, take us to an eminence from which we can
look down into the deep waters of philosophy; and if I rashly plunge
into them, it is not because I have confidence in my powers of
swimming, but to try to show that the water is really deep.
To put the conclusion crudely—the stuff of the world is mind-
stuff. As is often the way with crude statements, I shall have to
explain that by “mind” I do not here exactly mean mind and by
“stuff” I do not at all mean stuff. Still this is about as near as we can
get to the idea in a simple phrase. The mind-stuff of the world is, of
course, something more general than our individual conscious
minds; but we may think of its nature as not altogether foreign to
the feelings in our consciousness. The realistic matter and fields of
force of former physical theory are altogether irrelevant—except in
so far as the mind-stuff has itself spun these imaginings. The
symbolic matter and fields of force of present-day theory are more
relevant, but they bear to it the same relation that the bursar’s
accounts bear to the activity of the college. Having granted this, the
mental activity of the part of the world constituting ourselves
occasions no surprise; it is known to us by direct self-knowledge,
and we do not explain it away as something other than we know it
to be—or, rather, it knows itself to be. It is the physical aspects of
the world that we have to explain, presumably by some such
method as that set forth in our discussion on world-building. Our
bodies are more mysterious than our minds—at least they would be,
only that we can set the mystery on one side by the device of the
cyclic scheme of physics, which enables us to study their
phenomenal behaviour without ever coming to grips with the
underlying mystery.
The mind-stuff is not spread in space and time; these are part of
the cyclic scheme ultimately derived out of it. But we must presume
that in some other way or aspect it can be differentiated into parts.
Only here and there does it rise to the level of consciousness, but
from such islands proceeds all knowledge. Besides the direct
knowledge contained in each self-knowing unit, there is inferential
knowledge. The latter includes our knowledge of the physical world.
It is necessary to keep reminding ourselves that all knowledge of our
environment from which the world of physics is constructed, has
entered in the form of messages transmitted along the nerves to the
seat of consciousness. Obviously the messages travel in code. When
messages relating to a table are travelling in the nerves, the nerve-
disturbance does not in the least resemble either the external table
that originates the mental impression or the conception of the table
that arises in consciousness.[45] In the central clearing station the
incoming messages are sorted and decoded, partly by instinctive
image-building inherited from the experience of our ancestors, partly
by scientific comparison and reasoning. By this very indirect and
hypothetical inference all our supposed acquaintance with and our
theories of a world outside us have been built up. We are acquainted
with an external world because its fibres run into our consciousness;
it is only our own ends of the fibres that we actually know; from
those ends we more or less successfully reconstruct the rest, as a
palaeontologist reconstructs an extinct monster from its footprint.
The mind-stuff is the aggregation of relations and relata which
form the building material for the physical world. Our account of the
building process shows, however, that much that is implied in the
relations is dropped as unserviceable for the required building. Our
view is practically that urged in 1875 by W. K. Clifford—
“The succession of feelings which constitutes a man’s
consciousness is the reality which produces in our minds the
perception of the motions of his brain.”
That is to say, that which the man himself knows as a succession
of feelings is the reality which when probed by the appliances of an
outside investigator affects their readings in such a way that it is
identified as a configuration of brain-matter. Again Bertrand Russell
writes—[46]
What the physiologist sees when he examines a brain
is in the physiologist, not in the brain he is examining.
What is in the brain by the time the physiologist examines
it if it is dead, I do not profess to know; but while its
owner was alive, part, at least, of the contents of his brain
consisted of his percepts, thoughts, and feelings. Since his
brain also consisted of electrons, we are compelled to
conclude that an electron is a grouping of events, and that
if the electron is in a human brain, some of the events
composing it are likely to be some of the “mental states”
of the man to whom the brain belongs. Or, at any rate,
they are likely to be parts of such “mental states”—for it
must not be assumed that part of a mental state must be
a mental state. I do not wish to discuss what is meant by
a “mental state”; the main point for us is that the term
must include percepts. Thus a percept is an event or a
group of events, each of which belongs to one or more of
the groups constituting the electrons in the brain. This, I
think, is the most concrete statement that can be made
about electrons; everything else that can be said is more
or less abstract and mathematical.
I quote this partly for the sake of the remark that it must not be
assumed that part of a mental state must necessarily be a mental
state. We can no doubt analyse the content of consciousness during
a short interval of time into more or less elementary constituent
feelings; but it is not suggested that this psychological analysis will
reveal the elements out of whose measure-numbers the atoms or
electrons are built. The brain-matter is a partial aspect of the whole
mental state; but the analysis of the brain-matter by physical
investigation does not run at all parallel with the analysis of the
mental state by psychological investigation. I assume that Russell
meant to warn us that, in speaking of part of a mental state, he was
not limiting himself to parts that would be recognised as such
psychologically, and he was admitting a more abstract kind of
dissection.
This might give rise to some difficulty if we were postulating
complete identity of mind-stuff with consciousness. But we know
that in the mind there are memories not in consciousness at the
moment but capable of being summoned into consciousness. We are
vaguely aware that things we cannot recall are lying somewhere
about and may come into the mind at any moment. Consciousness is
not sharply defined, but fades into subconsciousness; and beyond
that we must postulate something indefinite but yet continuous with
our mental nature. This I take to be the world-stuff. We liken it to
our conscious feelings because, now that we are convinced of the
formal and symbolic character of the entities of physics, there is
nothing else to liken it to.
It is sometimes urged that the basal stuff of the world should be
called “neutral stuff” rather than “mind-stuff”, since it is to be such
that both mind and matter originate from it. If this is intended to
emphasise that only limited islands of it constitute actual minds, and
that even in these islands that which is known mentally is not
equivalent to a complete inventory of all that may be there, I agree.
In fact I should suppose that the self-knowledge of consciousness is
mainly or wholly a knowledge which eludes the inventory method of
description. The term “mind-stuff” might well be amended; but
neutral stuff seems to be the wrong kind of amendment. It implies
that we have two avenues of approach to an understanding of its
nature. We have only one approach, namely, through our direct
knowledge of mind. The supposed approach through the physical
world leads only into the cycle of physics, where we run round and
round like a kitten chasing its tail and never reach the world-stuff at
all.
I assume that we have left the illusion of substance so far behind
that the word “stuff” will not cause any misapprehension. I certainly
do not intend to materialise or substantialise mind. Mind is—but you
know what mind is like, so why should I say more about its nature?
The word “stuff” has reference to the function it has to perform as a
basis of world-building and does not imply any modified view of its
nature.
It is difficult for the matter-of-fact physicist to accept the view
that the substratum of everything is of mental character. But no one
can deny that mind is the first and most direct thing in our
experience, and all else is remote inference—inference either
intuitive or deliberate. Probably it would never have occurred to us
(as a serious hypothesis) that the world could be based on anything
else, had we not been under the impression that there was a rival
stuff with a more comfortable kind of “concrete” reality—something
too inert and stupid to be capable of forging an illusion. The rival
turns out to be a schedule of pointer readings; and though a world
of symbolic character can well be constructed from it, this is a mere
shelving of the inquiry into the nature of the world of experience.
This view of the relation of the material to the spiritual world
perhaps relieves to some extent a tension between science and
religion. Physical science has seemed to occupy a domain of reality
which is self-sufficient, pursuing its course independently of and
indifferent to that which a voice within us asserts to be a higher
reality. We are jealous of such independence. We are uneasy that
there should be an apparently self-contained world in which God
becomes an unnecessary hypothesis. We acknowledge that the ways
of God are inscrutable; but is there not still in the religious mind
something of that feeling of the prophets of old, who called on God
to assert his kingship and by sign or miracle proclaim that the forces
of Nature are subject to his command? And yet if the scientist were
to repent and admit that it was necessary to include among the
agents controlling the stars and the electrons an omnipresent spirit
to whom we trace the sacred things of consciousness, would there
not be even graver apprehension? We should suspect an intention to
reduce God to a system of differential equations, like the other
agents which at various times have been introduced to restore order
in the physical scheme. That fiasco at any rate is avoided. For the
sphere of the differential equations of physics is the metrical cyclic
scheme extracted out of the broader reality. However much the
ramifications of the cycles may be extended by further scientific
discovery, they cannot from their very nature trench on the
background in which they have their being—their actuality. It is in
this background that our own mental consciousness lies; and here, if
anywhere, we may find a Power greater than but akin to
consciousness. It is not possible for the controlling laws of the
spiritual substratum, which in so far as it is known to us in
consciousness is essentially non-metrical, to be analogous to the
differential and other mathematical equations of physics which are
meaningless unless they are fed with metrical quantities. So that the
crudest anthropomorphic image of a spiritual deity can scarcely be
so wide of the truth as one conceived in terms of metrical equations.
The Definition of Reality. It is time we came to grips with the loose
terms Reality and Existence, which we have been using without any
inquiry into what they are meant to convey. I am afraid of this word
Reality, not connoting an ordinarily definable characteristic of the
things it is applied to but used as though it were some kind of
celestial halo. I very much doubt if any one of us has the faintest
idea of what is meant by the reality or existence of anything but our
own Egos. That is a bold statement, which I must guard against
misinterpretation. It is, of course, possible to obtain consistent use
of the word “reality” by adopting a conventional definition. My own
practice would probably be covered by the definition that a thing
may be said to be real if it is the goal of a type of inquiry to which I
personally attach importance. But if I insist on no more than this I
am whittling down the significance that is generally assumed. In
physics we can give a cold scientific definition of reality which is free
from all sentimental mystification. But this is not quite fair play,
because the word “reality” is generally used with the intention of
evoking sentiment. It is a grand word for a peroration. “The right
honourable speaker went on to declare that the concord and amity
for which he had unceasingly striven had now become a reality (loud
cheers).” The conception which it is so troublesome to apprehend is
not “reality” but “reality (loud cheers)”.
Let us first examine the definition according to the purely
scientific usage of the word, although it will not take us far enough.
The only subject presented to me for study is the content of my
consciousness. You are able to communicate to me part of the
content of your consciousness which thereby becomes accessible in
my own. For reasons which are generally admitted, though I should
not like to have to prove that they are conclusive, I grant your
consciousness equal status with my own; and I use this second-hand
part of my consciousness to “put myself in your place”. Accordingly
my subject of study becomes differentiated into the contents of
many consciousnesses, each content constituting a view-point.
There then arises the problem of combining the view-points, and it is
through this that the external world of physics arises. Much that is in
any one consciousness is individual, much is apparently alterable by
volition; but there is a stable element which is common to other
consciousnesses. That common element we desire to study, to
describe as fully and accurately as possible, and to discover the laws
by which it combines now with one view-point, now with another.
This common element cannot be placed in one man’s consciousness
rather than in another’s; it must be in neutral ground—an external
world.
It is true that I have a strong impression of an external world
apart from any communication with other conscious beings. But
apart from such communication I should have no reason to trust the
impression. Most of our common impressions of substance, world-
wide instants, and so on, have turned out to be illusory, and the
externality of the world might be equally untrustworthy. The
impression of externality is equally strong in the world that comes to
me in dreams; the dreamworld is less rational, but that might be
used as an argument in favour of its externality as showing its
dissociation from the internal faculty of reason. So long as we have
to deal with one consciousness alone, the hypothesis that there is an
external world responsible for part of what appears in it is an idle
one. All that can be asserted of this external world is a mere
duplication of the knowledge that can be much more confidently
asserted of the world appearing in the consciousness. The
hypothesis only becomes useful when it is the means of bringing
together the worlds of many consciousnesses occupying different
view-points.
The external world of physics is thus a symposium of the worlds
presented to different view-points. There is general agreement as to
the principles on which the symposium should be formed.
Statements made about this external world, if they are
unambiguous, must be either true or false. This has often been
denied by philosophers. It is quite commonly said that scientific
theories about the world are neither true nor false but merely
convenient or inconvenient. A favourite phrase is that the gauge of
value of a scientific theory is that it economises thought. Certainly a
simple statement is preferable to a circumlocutory one; and as
regards any current scientific theory, it is much easier to show that it
is convenient or that it economises thought than that it is true. But
whatever lower standards we may apply in practice we need not
give up our ideals; and so long as there is a distinction between true
and false theories our aim must be to eliminate the false. For my
part I hold that the continual advance of science is not a mere
utilitarian progress; it is progress towards ever purer truth. Only let
it be understood that the truth we seek in science is the truth about
an external world propounded as the theme of study, and is not
bound up with any opinion as to the status of that world—whether
or not it wears the halo of reality, whether or not it is deserving of
“loud cheers”.
Assuming that the symposium has been correctly carried out, the
external world and all that appears in it are called real without
further ado. When we (scientists) assert of anything in the external
world that it is real and that it exists, we are expressing our belief
that the rules of the symposium have been correctly applied—that it
is not a false concept introduced by an error in the process of
synthesis, or a hallucination belonging to only one individual
consciousness, or an incomplete representation which embraces
certain view-points but conflicts with others. We refuse to
contemplate the awful contingency that the external world, after all
our care in arriving at it, might be disqualified by failing to exist;
because we have no idea what the supposed qualification would
consist in, nor in what way the prestige of the world would be
enhanced if it passed the implied test. The external world is the
world that confronts that experience which we have in common, and
for us no other world could fill the same rôle, no matter how high
honours it might take in the qualifying examination.
This domestic definition of existence for scientific purposes
follows the principle now adopted for all other definitions in science,
namely, that a thing must be defined according to the way in which
it is in practice recognised and not according to some ulterior
significance that we imagine it to possess. Just as matter must shed
its conception of substantiality, so existence must shed its halo,
before we can admit it into physical science. But clearly if we are to
assert or to question the existence of anything not comprised in the
external world of physics, we must look beyond the physical
definition. The mere questioning of the reality of the physical world
implies some higher censorship than the scientific method itself can
supply.
The external world of physics has been formulated as an answer
to a particular problem encountered in human experience. Officially
the scientist regards it as a problem which he just happened across,
as he might take up a cross-word problem encountered in a news-
paper. His sole business is to see that the problem is correctly
solved. But questions may be raised about a problem which play no
part and need not be considered in connection with the solving of
the problem. The extraneous question naturally raised about the
problem of the external world is whether there is some higher
justification for embarking on this world-solving competition rather
than on other problems which our experience might suggest to us.
Just what kind of justification the scientist would claim for his quest
is not very clear, because it is not within the province of science to
formulate such a claim. But certainly he makes claims which do not
rest on the aesthetic perfection of the solution or on material
benefits derived from scientific research. He would not allow his
subject to be shoved aside in a symposium on truth. We can scarcely
say anything more definite than that science claims a “halo” for its
world.
If we are to find for the atoms and electrons of the external
world not merely a conventional reality but “reality (loud cheers)” we
must look not to the end but to the beginning of the quest. It is at
the beginning that we must find that sanction which raises these
entities above the mere products of an arbitrary mental exercise.
This involves some kind of assessment of the impulse which sets us
forth on the voyage of discovery. How can we make such
assessment? Not by any reasoning that I know of. Reasoning would
only tell us that the impulse might be judged by the success of the
adventure—whether it leads in the end to things which really exist
and wear the halo in their own right; it takes us to and fro like a
shuttle along the chain of inference in vain search for the elusive
halo. But, legitimately or not, the mind is confident that it can
distinguish certain quests as sanctioned by indisputable authority.
We may put it in different ways the impulse to this quest is part of
our very nature; it is the expression of a purpose which has
possession of us. Is this precisely what we meant when we sought
to affirm the reality of the external world? It goes some way towards
giving it a meaning but is scarcely the full equivalent. I doubt if we
really satisfy the conceptions behind that demand unless we make
the bolder hypothesis that the quest and all that is reached by it are
of worth in the eyes of an Absolute Valuer.
Whatever justification at the source we accept to vindicate the
reality of the external world, it can scarcely fail to admit on the same
footing much that is outside physical science. Although no long
chains of regularised inference depend from them we recognise that
other fibres of our being extend in directions away from sense-
impressions. I am not greatly concerned to borrow words like
“existence” and “reality” to crown these other departments of the
soul’s interest. I would rather put it that any raising of the question
of reality in its transcendental sense (whether the question
emanates from the world of physics or not) leads us to a perspective
from which we see man not as a bundle of sensory impressions, but
conscious of purpose and responsibilities to which the external world
is subordinate.
From this perspective we recognise a spiritual world alongside
the physical world. Experience—that is to say, the self cum
environment—comprises more than can be embraced in the physical
world, restricted as it is to a complex of metrical symbols. The
physical world is, we have seen, the answer to one definite and
urgent problem arising in a survey of experience; and no other
problem has been followed up with anything like the same precision
and elaboration. Progress towards an understanding of the non-
sensory constituents of our nature is not likely to follow similar lines,
and indeed is not animated by the same aims. If it is felt that this
difference is so wide that the phrase spiritual world is a misleading
analogy, I will not insist on the term. All I would claim is that those
who in the search for truth start from consciousness as a seat of
self-knowledge with interests and responsibilities not confined to the
material plane, are just as much facing the hard facts of experience
as those who start from consciousness as a device for reading the
indications of spectroscopes and micrometers.

Physical Illustrations. If the reader is unconvinced that there can be


anything indefinite in the question whether a thing exists or not, let
him glance at the following problem. Consider a distribution of
matter in Einstein’s spherical “finite but unbounded” space. Suppose
that the matter is so arranged that every particle has an exactly
similar particle at its antipodes. (There is some reason to believe
that the matter would necessarily have this arrangement in
consequence of the law of gravitation; but this is not certain.) Each
group of particles will therefore be exactly like the antipodal group
not only in its structure and configuration but in its entire
surroundings; the two groups will in fact be indistinguishable by any
possible experimental test. Starting on a journey round the spherical
world we come across a group , and then after going half round
we come to an exactly similar group indistinguishable by any
test; another half circle again brings us to an exactly similar group,
which, however, we decide is the original group . Now let us
ponder a little. We realise that in any case by going on far enough
we come back to the same group. Why do we not accept the
obvious conclusion that this happened when we reached ;
everything was exactly as though we had reached the starting-point
again? We have encountered a succession of precisely similar
phenomena but for some arbitrary reason have decided that only the
alternate ones are really the same. There is no difficulty in
identifying all of them; in that case the space is “elliptical” instead of
“spherical”. But which is the real truth? Disregard the fact that I
introduced and to you as though they were not the same
particles, because that begs the question; imagine that you have
actually had this adventure in a world you had not been told about.
You cannot find out the answer. Can you conceive what the question
means? I cannot. All that turns on the answer is whether we shall
provide two separate haloes for and or whether one will
suffice.
Descriptions of the phenomena of atomic physics have an
extraordinary vividness. We see the atoms with their girdles of
circulating electrons darting hither and thither, colliding and
rebounding. Free electrons torn from the girdles hurry away a
hundred times faster, curving sharply round the atoms with side slips
and hairbreadth escapes. The truants are caught and attached to
the girdles and the escaping energy shakes the aether into vibration.
X-rays impinge on the atoms and toss the electrons into higher
orbits. We see these electrons falling back again, sometimes by
steps, sometimes with a rush, caught in a cul-de-sac of
metastability, hesitating before “forbidden passages”. Behind it all
the quantum regulates each change with mathematical precision.
This is the sort of picture that appeals to our understanding—no
insubstantial pageant to fade like a dream.
The spectacle is so fascinating that we have perhaps forgotten
that there was a time when we wanted to be told what an electron
is. The question was never answered. No familiar conceptions can be
woven round the electron; it belongs to the waiting list. Similarly the
description of the processes must be taken with a grain of salt. The
tossing up of the electron is a conventional way of depicting a
particular change of state of the atom which cannot really be
associated with movements in space as macroscopically conceived.
Something unknown is doing we don’t know what—that is what our
theory amounts to. It does not sound a particularly illuminating
theory. I have read something like it elsewhere—

The slithy toves


Did gyre and gimble in the wabe.
There is the same suggestion of activity. There is the same
indefiniteness as to the nature of the activity and of what it is that is
acting. And yet from so unpromising a beginning we really do get
somewhere. We bring into order a host of apparently unrelated
phenomena; we make predictions, and our predictions come off. The
reason—the sole reason—for this progress is that our description is
not limited to unknown agents executing unknown activities, but
numbers are scattered freely in the description. To contemplate
electrons circulating in the atom carries us no further; but by
contemplating eight circulating electrons in one atom and seven
circulating electrons in another we begin to realise the difference
between oxygen and nitrogen. Eight slithy toves gyre and gimble in
the oxygen wabe; seven in nitrogen. By admitting a few numbers
even “Jabberwocky” may become scientific. We can now venture on
a prediction; if one of its toves escapes, oxygen will be
masquerading in a garb properly belonging to nitrogen. In the stars
and nebulae we do find such wolves in sheep’s clothing which might
otherwise have startled us. It would not be a bad reminder of the
essential unknownness of the fundamental entities of physics to
translate it into “Jabberwocky”; provided all numbers—all metrical
attributes—are unchanged, it does not suffer in the least. Out of the
numbers proceeds that harmony of natural law which it is the aim of
science to disclose. We can grasp the tune but not the player.
Trinculo might have been referring to modern physics in the words,
“This is the tune of our catch, played by the picture of Nobody”.
[45] I mean, resemble in intrinsic nature. It is true (as Bertrand
Russell has emphasised) that the symbolic description of structure
will be identical for the table in the external world and for the
conception of the table in consciousness if the conception is
scientifically correct. If the physicist does not attempt to
penetrate beneath the structure he is indifferent as to which of
the two we imagine ourselves to be discussing.
[46] Analysis of Matter, p. 320.
Chapter XIV
CAUSATION
In the old conflict between freewill and predestination it has seemed
hitherto that physics comes down heavily on the side of
predestination. Without making extravagant claims for the scope of
natural law, its moral sympathy has been with the view that
whatever the future may bring forth is already foretold in the
configurations of the past—

Yea, the first Morning of Creation wrote


What the Last Dawn of Reckoning shall read.

I am not so rash as to invade Scotland with a solution of a


problem which has rent her from the synod to the cottage. Like most
other people, I suppose, I think it incredible that the wider scheme
of Nature which includes life and consciousness can be completely
predetermined; yet I have not been able to form a satisfactory
conception of any kind of law or causal sequence which shall be
other than deterministic. It seems contrary to our feeling of the
dignity of the mind to suppose that it merely registers a dictated
sequence of thoughts and emotions; but it seems equally contrary to
its dignity to put it at the mercy of impulses with no causal
antecedents. I shall not deal with this dilemma. Here I have to set
forth the position of physical science on this matter so far as it
comes into her territory. It does come into her territory, because that
which we call human will cannot be entirely dissociated from the
consequent motions of the muscles and disturbance of the material
world. On the scientific side a new situation has arisen. It is a
consequence of the advent of the quantum theory that physics is no
longer pledged to a scheme of deterministic law. Determinism has
dropped out altogether in the latest formulations of theoretical
physics and it is at least open to doubt whether it will ever be
brought back.
The foregoing paragraph is from the manuscript of the original
lecture delivered in Edinburgh. The attitude of physics at that time
was one of indifference to determinism. If there existed a scheme of
strictly causal law at the base of phenomena the search for it was
not at present practical politics, and meanwhile another ideal was
being pursued. The fact that a causal basis had been lost sight of in
the new theories was fairly well known; many regretted it, and held
that its restoration was imperative.[47]
In rewriting this chapter a year later I have had to mingle with
this attitude of indifference an attitude more definitely hostile to
determinism which has arisen from the acceptance of the Principle of
Indeterminacy (p. 220). There has been no time for more than a
hurried examination of the far-reaching consequences of this
principle; and I should have been reluctant to include “stop-press”
ideas were it not that they appear to clinch the conception towards
which the earlier developments were leading. The future is a
combination of the causal influences of the past together with
unpredictable elements—unpredictable not merely because it is
impracticable to obtain the data of prediction, but because no data
connected causally with our experience exist. It will be necessary to
defend so remarkable a change of opinion at some length.
Meanwhile we may note that science thereby withdraws its moral
opposition to freewill. Those who maintain a deterministic theory of
mental activity must do so as the outcome of their study of the mind
itself and not with the idea that they are thereby making it more
conformable with our experimental knowledge of the laws of
inorganic nature.

Causation and Time’s Arrow. Cause and effect are closely bound up
with time’s arrow; the cause must precede the effect. The relativity
of time has not obliterated this order. An event Here-Now can only
cause events in the cone of absolute future; it can be caused by
events in the cone of absolute past; it can neither cause nor be
caused by events in the neutral wedge, since the necessary
influence would in that case have to be transmitted with a speed
faster than light. But curiously enough this elementary notion of
cause and effect is quite inconsistent with a strictly causal scheme.
How can I cause an event in the absolute future, if the future was
predetermined before I was born? The notion evidently implies that
something may be born into the world at the instant Here-Now,
which has an influence extending throughout the future cone but no
corresponding linkage to the cone of absolute past. The primary
laws of physics do not provide for any such one-way linkage; any
alteration in a prescribed state of the world implies alterations in its
past state symmetrical with the alterations in its future state. Thus in
primary physics, which knows nothing of time’s arrow, there is no
discrimination of cause and effect; but events are connected by a
symmetrical causal relation which is the same viewed from either
end.
Primary physics postulates a strictly causal scheme, but the
causality is a symmetrical relation and not the one-way relation of
cause and effect. Secondary physics can distinguish cause and effect
but its foundation does not rest on a causal scheme and it is
indifferent as to whether or not strict causality prevails.
The lever in a signal box is moved and the signal drops. We can
point out the relation of constraint which associates the positions of
lever and signal; we can also find that the movements are not
synchronous, and calculate the time-difference. But the laws of
mechanics do not ascribe an absolute sign to this time-difference; so
far as they are concerned we may quite well suppose that the drop
of the signal causes the motion of the lever. To settle which is the
cause, we have two options. We can appeal to the signalman who is
confident that he made the mental decision to pull the lever; but this
criterion will only be valid if we agree that there was a genuine
decision between two possible courses and not a mere mental
registration of what was already predetermined. Or we can appeal to

You might also like