PHP and MySQL Web Development 5th Edition Developer S Library Luke Welling - The Ebook Is Available For Online Reading or Easy Download
PHP and MySQL Web Development 5th Edition Developer S Library Luke Welling - The Ebook Is Available For Online Reading or Easy Download
com
https://textbookfull.com/product/php-and-mysql-web-
development-5th-edition-developer-s-library-luke-welling/
OR CLICK HERE
DOWLOAD EBOOK
PHP and MySQL for Dynamic Web Sites Fifth Edition Ullman
https://textbookfull.com/product/php-and-mysql-for-dynamic-web-sites-
fifth-edition-ullman/
textbookfull.com
https://textbookfull.com/product/the-object-oriented-thought-process-
developer-s-library-5th-edition-weisfeld/
textbookfull.com
https://textbookfull.com/product/beginning-php-and-mysql-from-novice-
to-professional-5th-edition-frank-m-kromann/
textbookfull.com
https://textbookfull.com/product/learning-php-mysql-javascript-with-
jquery-css-html5-5th-edition-robin-nixon/
textbookfull.com
Web App Development Made Simple with Streamlit A web
developer s guide to effortless web app development
deployment 1 / converted Edition Rosario Moscato
https://textbookfull.com/product/web-app-development-made-simple-with-
streamlit-a-web-developer-s-guide-to-effortless-web-app-development-
deployment-1-converted-edition-rosario-moscato/
textbookfull.com
PHP for the Web Visual QuickStart Guide 5th Edition Larry
Ullman
https://textbookfull.com/product/php-for-the-web-visual-quickstart-
guide-5th-edition-larry-ullman/
textbookfull.com
https://textbookfull.com/product/learning-php-mysql-javascript-6th-
edition-robin-nixon/
textbookfull.com
Luke Welling
Laura Thomson
Trademarks
All terms mentioned in this book that are known to be trademarks or
service marks have been appropriately capitalized. Pearson cannot
attest to the accuracy of this information. Use of a term in this book
should not be regarded as affecting the validity of any trademark or
service mark.
Key titles include some of the best, most widely acclaimed books
within their topic areas:
Developer’s Library
informit.com/devlibrary
Contents at a Glance
Introduction
I: Using PHP
1 PHP Crash Course
2 Storing and Retrieving Data
3 Using Arrays
4 String Manipulation and Regular Expressions
5 Reusing Code and Writing Functions
6 Object-Oriented PHP
7 Error and Exception Handling
II: Using MySQL
8 Designing Your Web Database
9 Creating Your Web Database
10 Working with Your MySQL Database
11 Accessing Your MySQL Database from the Web with PHP
12 Advanced MySQL Administration
13 Advanced MySQL Programming
III: Web Application Security
14 Web Application Security Risks
15 Building a Secure Web Application
16 Implementing Authentication Methods with PHP
IV: Advanced PHP Techniques
17 Interacting with the File System and the Server
18 Using Network and Protocol Functions
19 Managing the Date and Time
20 Internationalization and Localization
21 Generating Images
22 Using Session Control in PHP
23 Integrating JavaScript and PHP
24 Other Useful Features
V: Building Practical PHP and MySQL Projects
25 Using PHP and MySQL for Large Projects
26 Debugging and Logging
27 Building User Authentication and Personalization
28 Building a Web-Based Email Service with Laravel Part I Web
Edition
29 Building a Web-Based Email Service with Laravel Part II Web
Edition
30 Social Media Integration Sharing and Authentication Web Edition
31 Building a Shopping Cart Web Edition
VI: Appendix
A Installing Apache, PHP, and MySQL
Index
Table of Contents
Introduction
I: Using PHP
1 PHP Crash Course
Before You Begin: Accessing PHP
Creating a Sample Application: Bob’s Auto Parts
Creating the Order Form
Processing the Form
Embedding PHP in HTML
PHP Tags
PHP Statements
Whitespace
Comments
Adding Dynamic Content
Calling Functions
Using the date() Function
Accessing Form Variables
Form Variables
String Concatenation
Variables and Literals
Understanding Identifiers
Examining Variable Types
PHP’s Data Types
Type Strength
Type Casting
Variable Variables
Declaring and Using Constants
Understanding Variable Scope
Using Operators
Arithmetic Operators
String Operators
Assignment Operators
Comparison Operators
Logical Operators
Bitwise Operators
Other Operators
Working Out the Form Totals
Understanding Precedence and Associativity
Using Variable Handling Functions
Testing and Setting Variable Types
Testing Variable Status
Reinterpreting Variables
Making Decisions with Conditionals
if Statements
Code Blocks
else Statements
elseif Statements
switch Statements
Comparing the Different Conditionals
Repeating Actions Through Iteration
while Loops
for and foreach Loops
do...while Loops
Breaking Out of a Control Structure or Script
Employing Alternative Control Structure Syntax
Using declare
Next
2 Storing and Retrieving Data
Saving Data for Later
Storing and Retrieving Bob’s Orders
Processing Files
Opening a File
Choosing File Modes
Using fopen() to Open a File
Opening Files Through FTP or HTTP
Addressing Problems Opening Files
Writing to a File
Parameters for fwrite()
File Formats
Closing a File
Reading from a File
Opening a File for Reading: fopen()
Knowing When to Stop: feof()
Reading a Line at a Time: fgets(), fgetss(), and
fgetcsv()
Reading the Whole File: readfile(), fpassthru(),
file(), and file_get_contents()
Reading a Character: fgetc()
Reading an Arbitrary Length: fread()
Using Other File Functions
Checking Whether a File Is There: file_exists()
Determining How Big a File Is: filesize()
Deleting a File: unlink()
Navigating Inside a File: rewind(), fseek(), and ftell()
Locking Files
A Better Way: Databases
Problems with Using Flat Files
How RDBMSs Solve These Problems
Further Reading
Next
3 Using Arrays
What Is an Array?
Numerically Indexed Arrays
Initializing Numerically Indexed Arrays
Accessing Array Contents
Using Loops to Access the Array
Arrays with Different Indices
Initializing an Array
Accessing the Array Elements
Using Loops
Array Operators
Multidimensional Arrays
Sorting Arrays
Using sort()
Using asort() and ksort() to Sort Arrays
Sorting in Reverse
Sorting Multidimensional Arrays
Using the array_multisort() function
User-Defined Sorts
Reverse User Sorts
Reordering Arrays
Using shuffle()
Reversing an Array
Loading Arrays from Files
Performing Other Array Manipulations
Navigating Within an Array: each(), current(), reset(),
end(), next(), pos(), and prev()
Applying Any Function to Each Element in an Array:
array_walk()
Counting Elements in an Array: count(), sizeof(), and
array_count_values()
Converting Arrays to Scalar Variables: extract()
Further Reading
Next
4 String Manipulation and Regular Expressions
Creating a Sample Application: Smart Form Mail
Formatting Strings
Trimming Strings: chop(), ltrim(), and trim()
Formatting Strings for Output
Joining and Splitting Strings with String Functions
Using explode(), implode(), and join()
Using strtok()
Using substr()
Comparing Strings
Performing String Ordering: strcmp(), strcasecmp(), and
strnatcmp()
Testing String Length with strlen()
Matching and Replacing Substrings with String Functions
Finding Strings in Strings: strstr(), strchr(),
strrchr(), and stristr()
Finding the Position of a Substring: strpos() and
strrpos()
Replacing Substrings: str_replace() and
substr_replace()
Introducing Regular Expressions
The Basics
Delimiters
Character Classes and Types
Repetition
Subexpressions
Counted Subexpressions
Anchoring to the Beginning or End of a String
Branching
Matching Literal Special Characters
Reviewing Meta Characters
Escape Sequences
Backreferences
Assertions
Putting It All Together for the Smart Form
Finding Substrings with Regular Expressions
Replacing Substrings with Regular Expressions
Splitting Strings with Regular Expressions
Further Reading
Next
5 Reusing Code and Writing Functions
The Advantages of Reusing Code
Cost
Reliability
Consistency
Using require() and include()
Using require() to Include Code
Using require() for Website Templates
Using auto_prepend_file and auto_append_file
Using Functions in PHP
Calling Functions
Calling an Undefined Function
Understanding Case and Function Names
Defining Your Own Functions
Examining Basic Function Structure
Naming Your Function
Using Parameters
Understanding Scope
Passing by Reference Versus Passing by Value
Using the return Keyword
Returning Values from Functions
Implementing Recursion
Implementing Anonymous Functions (or Closures)
Further Reading
Next
6 Object-Oriented PHP
Understanding Object-Oriented Concepts
Classes and Objects
Polymorphism
Inheritance
Creating Classes, Attributes, and Operations in PHP
Structure of a Class
Constructors
Destructors
Instantiating Classes
Using Class Attributes
Calling Class Operations
Controlling Access with private and public
Writing Accessor Functions
Implementing Inheritance in PHP
Controlling Visibility Through Inheritance with private and
protected
Overriding
Preventing Inheritance and Overriding with final
Understanding Multiple Inheritance
Implementing Interfaces
Using Traits
Designing Classes
Writing the Code for Your Class
Understanding Advanced Object-Oriented Functionality in PHP
Using Per-Class Constants
Implementing Static Methods
Checking Class Type and Type Hinting
Late Static Bindings
Cloning Objects
Using Abstract Classes
Overloading Methods with __call()
Using __autoload()
Implementing Iterators and Iteration
Generators
Converting Your Classes to Strings
Using the Reflection API
Namespaces
Using Subnamespaces
Understanding the Global Namespace
Importing and Aliasing Namespaces
Next
7 Error and Exception Handling
Exception Handling Concepts
The Exception Class
User-Defined Exceptions
Exceptions in Bob’s Auto Parts
Exceptions and PHP’s Other Error Handling Mechanisms
Further Reading
Next
II: Using MySQL
8 Designing Your Web Database
Relational Database Concepts
Tables
Columns
Rows
Values
Keys
Schemas
Relationships
Designing Your Web Database
Think About the Real-World Objects You Are Modeling
Avoid Storing Redundant Data
Use Atomic Column Values
Choose Sensible Keys
Think About What You Want to Ask the Database
Avoid Designs with Many Empty Attributes
Summary of Table Types
Web Database Architecture
Further Reading
Next
9 Creating Your Web Database
Using the MySQL Monitor
Logging In to MySQL
Creating Databases and Users
Setting Up Users and Privileges
Introducing MySQL’s Privilege System
Principle of Least Privilege
User Setup: The CREATE USER and GRANT Commands
Types and Levels of Privileges
The REVOKE Command
Examples Using GRANT and REVOKE
Setting Up a User for the Web
Using the Right Database
Creating Database Tables
Understanding What the Other Keywords Mean
Understanding the Column Types
Looking at the Database with SHOW and DESCRIBE
Creating Indexes
Understanding MySQL Identifiers
Choosing Column Data Types
Numeric Types
Date and Time Types
String Types
Further Reading
Next
10 Working with Your MySQL Database
What Is SQL?
Inserting Data into the Database
Retrieving Data from the Database
Retrieving Data with Specific Criteria
Retrieving Data from Multiple Tables
Retrieving Data in a Particular Order
Grouping and Aggregating Data
Choosing Which Rows to Return
Using Subqueries
Updating Records in the Database
Altering Tables After Creation
Deleting Records from the Database
Dropping Tables
Dropping a Whole Database
Further Reading
Next
11 Accessing Your MySQL Database from the Web with PHP
How Web Database Architectures Work
Querying a Database from the Web
Checking and Filtering Input Data
Setting Up a Connection
Choosing a Database to Use
Querying the Database
Using Prepared Statements
Retrieving the Query Results
Disconnecting from the Database
Putting New Information in the Database
Using Other PHP-Database Interfaces
Using a Generic Database Interface: PDO
Further Reading
Next
12 Advanced MySQL Administration
Understanding the Privilege System in Detail
The user Table
The db Table
The tables_priv, columns_priv, and procs priv
Tables
Access Control: How MySQL Uses the Grant Tables
Updating Privileges: When Do Changes Take Effect?
Making Your MySQL Database Secure
MySQL from the Operating System’s Point of View
Passwords
User Privileges
Web Issues
Getting More Information About Databases
Getting Information with SHOW
Getting Information About Columns with DESCRIBE
Understanding How Queries Work with EXPLAIN
Optimizing Your Database
Design Optimization
Permissions
Table Optimization
Using Indexes
Using Default Values
Other Tips
Backing Up Your MySQL Database
Restoring Your MySQL Database
Implementing Replication
Setting Up the Master
Performing the Initial Data Transfer
Setting Up the Slave or Slaves
Further Reading
Next
13 Advanced MySQL Programming
The LOAD DATA INFILE Statement
Storage Engines
Transactions
Understanding Transaction Definitions
Using Transactions with InnoDB
Foreign Keys
Stored Procedures
Basic Example
Local Variables
Cursors and Control Structures
Triggers
Further Reading
Next
III: Web Application Security
14 Web Application Security Risks
Identifying the Threats We Face
Access to Sensitive Data
Modification of Data
Loss or Destruction of Data
Denial of Service
Malicious Code Injection
Compromised Server
Repudiation
Understanding Who We’re Dealing With
Attackers and Crackers
Unwitting Users of Infected Machines
Disgruntled Employees
Hardware Thieves
Ourselves
Next
15 Building a Secure Web Application
Strategies for Dealing with Security
Start with the Right Mindset
Balancing Security and Usability
Monitoring Security
Our Basic Approach
Securing Your Code
Filtering User Input
Escaping Output
Code Organization
What Goes in Your Code
File System Considerations
Code Stability and Bugs
Executing Commands
Securing Your Web Server and PHP
Keep Software Up-to-Date
Browse the php.ini file
Web Server Configuration
Shared Hosting of Web Applications
Database Server Security
Users and the Permissions System
Sending Data to the Server
Connecting to the Server
Running the Server
Protecting the Network
Firewalls
Use a DMZ
Prepare for DoS and DDoS Attacks
Computer and Operating System Security
Keep the Operating System Up to Date
Run Only What Is Necessary
Physically Secure the Server
Disaster Planning
Next
16 Implementing Authentication Methods with PHP
Identifying Visitors
Implementing Access Control
Storing Passwords
Securing Passwords
Another Random Document on
Scribd Without Any Related Topics
The Project Gutenberg eBook of The Scientific
Basis of Morals, and Other Essays
This ebook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this ebook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.
Language: English
MORALS,
Covers for the Library, to hold firmly any number of copies from one to
twelve, Price, 60 cents; to Subscribers, 35 cents.
J. FITZGERALD, PUBLISHER,
20 LAFAYETTE PLACE,
NEW YORK.
HUMBOLDT LIBRARY
OF
MORALS,
Viz.: Right and Wrong; The Ethics of Belief; The Ethics of Religion.
The Tribal Self.—In the metaphysical sense, the word ‘self’ is taken to
mean the conscious subject, das Ich, the whole stream of feelings which
make up a consciousness regarded as bound together by association and
memory. But, in the more common and more restricted ethical sense, what
we call self is a selected aggregate of feelings and of objects related to
them, which hangs together as a conception by virtue of long and repeated
association. My self does not include all my feelings, because habitually
separate off some of them, say they do not properly belong to me, and treat
them as my enemies. On the other hand, it does in general include my body
regarded as an object, because of the feelings which occur simultaneously
with events which affect it. My foot is certainly part of myself, because I
get hurt when anybody treads on it. When we desire anything for its
somewhat remote consequences, it is not common for these to be
represented to the mind in the form of the actual feelings of pleasure which
are ultimately to flow from the satisfaction of the desire; instead of this,
they are replaced by a symbolic conception which represents the thing
desired as doing good to the complex abstraction self. This abstraction
serves thus to support and hold together those complex and remote motives
which make up by far the greater part of the life of the intelligent races.
When a thing is desired for no immediate pleasure that it can bring, it is
generally desired on account of a certain symbolic substitute for pleasure,
the feeling that this thing is suitable to the self. And, as in many like cases,
this feeling, which at first derived its pleasurable nature from the faintly
represented simple pleasures of which it was a symbol, ceases after a time
to recall them and becomes a simple pleasure itself. In this way the self
becomes a sort of center about which our remoter motives revolve, and to
which they always have regard; in virtue of which, moreover, they become
immediate and simple, from having been complex and remote.
If we consider now the simpler races of mankind, we shall find not only that
immediate desires play a far larger part in their lives, and so that the
conception of self is less used and less developed, but also that it is less
definite and more wide. The savage is not only hurt when anybody treads
on his foot, but when anybody treads on his tribe. He may lose his hut, and
his wife, and his opportunities of getting food. In this way the tribe becomes
naturally included in that conception of self which renders remote desires
possible by making them immediate. The actual pains or pleasures which
come from the woe or weal of the tribe, and which were the source of this
conception, drop out of consciousness and are remembered no more; the
symbol which has replaced them becomes a center and goal of immediate
desires, powerful enough in many cases to override the strongest
suggestions of individual pleasure or pain.
Here a helping cause comes in. The tribe, quâ tribe, has to exist, and it can
only exist by aid of such an organic artifice as the conception of the tribal
self in the minds of its members. Hence the natural selection of those races
in which this conception is the most powerful and most habitually
predominant as a motive over immediate desires. To such an extent has this
proceeded that we may fairly doubt whether the selfhood of the tribe is not
earlier in point of development than that of the individual. In the process of
time it becomes a matter of hereditary transmission, and is thus fixed as a
specific character in the constitution of social man. With the settlement of
countries, and the aggregation of tribes into nations, it takes a wider and
more abstract form; and in the highest natures the tribal self is incarnate in
nothing less than humanity. Short of these heights, it places itself in the
family and in the city. I shall call that quality or disposition of man which
consists in the supremacy of the family or tribal self as a mark of reference
for motives by its old name Piety. And I have now to consider certain
feelings and conceptions to which the existence of piety must necessarily
give rise.
The word tribe is here used to mean a group of that size which in the
circumstances considered is selected for survival or destruction as a group.
Self-regarding excellences are brought out by the natural selection of
individuals; the tribal self is developed by the natural selection of groups.
The size of the groups must vary at different times; and the extent of the
tribal self must vary accordingly.
Now suppose that a man has done something obviously harmful to the
community. Either some immediate desire, or his individual self, has for
once proved stronger than the tribal self. When the tribal self wakes up, the
man says, ‘In the name of the tribe, I do not like this thing that I, as an
individual, have done.’ This Self-judgment in the name of the tribe is called
Conscience. If the man goes further and draws from this act and others an
inference about his own character, he may say, ‘In the name of the tribe, I
do not like my individual self.’ This is remorse. Mr. Darwin has well
pointed out that immediate desires are in general strong but of short
duration, and cannot be adequately represented to the mind after they have
passed; while the social forces, though less violent, have a steady and
continuous action.
Let us note now the very important difference between the direct and the
reflex process. To clear a man away as a noxious beast, and to punish him
for doing wrong, these are two very different things. The purpose in the first
case is merely to get rid of a nuisance; the purpose in the second case is to
improve the character either of the man himself or of those who will
observe this public expression of disapprobation. The offense of which the
man has been guilty leads to an inference about his character, and it is
supposed that the community may contain other persons whose characters
are similar to his, or tend to become so. It has been found that the
expression of public disapprobation tends to awake the conscience of such
people and to improve their characters. If the improvement of the man
himself is aimed at, it is assumed that he has a conscience which can be
worked upon and made to deter him from similar offenses in future.
The word purpose has here been used in a sense to which it is perhaps
worth while to call attention. Adaptation of means to an end may be
produced in two ways that we at present know of; by processes of natural
selection, and by the agency of an intelligence in which an image or idea of
the end preceded the use of the means. In both cases the existence of the
adaptation is accounted for by the necessity or utility of the end. It seems to
me convenient to use the word purpose as meaning generally the end to
which certain means are adapted, both in these two cases, and in any other
that may hereafter become known, provided only that the adaptation is
accounted for by the necessity or utility of the end. And there seems no
objection to the use of the phrase ‘final cause’ in this wider sense, if it is to
be kept at all. The word ‘design’ might then be kept for the special case of
adaptation by an intelligence. And we may then say that since the process of
natural selection has been understood, purpose has ceased to suggest design
to instructed people, except in cases where the agency of man is
independently probable.
When a man can be punished for doing wrong with approval of the tribal
self, he is said to be responsible. Responsibility implies two things:—(1)
The act was a product of the man’s character and of the circumstances, and
his character may to a certain extent be inferred from the act; (2) The man
had a conscience which might have been so worked upon as to prevent his
doing the act. Unless the first condition be fulfilled, we cannot reasonably
take any action at all in regard to the man, but only in regard to the offense.
In the case of crimes of violence, for example, we might carry a six-shooter
to protect ourselves against similar possibilities, but unless the fact of a
man’s having once committed a murder made it probable that he would do
the like again, it would clearly be absurd and unreasonable to lynch the
man. That is to say, we assume an uniformity of connection between
character and actions, infer a man’s character from his past actions, and
endeavor to provide against his future actions either by destroying him or
by changing his character. I think it will be found that in all those cases
where we not only deal with the offense but treat it with moral reprobation,
we imply the existence of a conscience which might have been worked
upon to improve the character. Why, for example, do we not regard a lunatic
as responsible? Because we are in possession of information about his
character derived not only from his one offense but from other facts,
whereby we know that even if he had a conscience left, his mind is so
diseased that it is impossible by moral reprobation alone to change his
character so that it may be subsequently relied upon. With his cure from
disease and the restored validity of this condition, responsibility returns.
There are, of course, cases in which an irresponsible person is punished as
if he were responsible, pour encourager les autres who are responsible. The
question of the right or wrong of this procedure is the question of its
average effect on the character of men at any particular time.
Ethics are based on Uniformity.—I have already observed that to deal with
men as a means of influencing their actions implies that these actions are a
product of character and circumstances; and that moral reprobation and
responsibility cannot exist unless we assume the efficacy of certain special
means of influencing character. It is not necessary to point out that such
considerations involve that uniformity of nature which underlies the
possibility of even unconscious adaptations to experience, of language, and
of general conceptions and statements. It may be asked, ‘Are you quite sure
that these observed uniformities between motive and action, between
character and motive, between social influence and change of character, are
absolutely exact in the form in which you state them, or indeed that they are
exact laws of any form? May there not be very slight divergences from
exact laws, which will allow of the action of an “uncaused will,” or of the
interference of some “extra-mundane force”?’ I am sure I do not know. But
this I do know: that our sense of right and wrong is derived from such order
as we can observe, and not from such caprice of disorder as we may
fancifully conjecture; and that to whatever extent a divergence from
exactness became sensible, to that extent it would destroy the most
widespread and worthy of the acquisitions of mankind.
First, then, Ethic is a matter of the tribe or community, and therefore there
are no ‘self-regarding virtues.’ The qualities of courage, prudence, etc., can
only be rightly encouraged in so far as they are shown to conduce to the
efficiency of a citizen; that is, in so far as they cease to be self-regarding.
The duty of private judgment, of searching after truth, the sacredness of
belief which ought not to be misused on unproved statements, follow only
on showing of the enormous importance to society of a true knowledge of
things. And any diversion of conscience from its sole allegiance to the
community is condemned à priori in the very nature of right and wrong.
Next, the end of Ethic is not the greatest happiness of the greatest number.
Your happiness is of no use to the community, except in so far as it tends to
make you a more efficient citizen—that is to say, happiness is not to be
desired for its own sake, but for the sake of something else. If any end is
pointed to, it is the end of increased efficiency in each man’s special work,
as well as in the social functions which are common to all. A man must
strive to be a better citizen, a better workman, a better son, husband, or
father.
Again, Piety is not Altruism. It is not the doing good to others as others, but
the service of the community by a member of it, who loses in that service
the consciousness that he is anything different from the community.
The social organism, like the individual, may be healthy or diseased. Health
and disease are very difficult things to define accurately: but for practical
purposes, there are certain states about which no mistake can be made.
When we have even a very imperfect catalogue and description of states
that are clearly and certainly diseases, we may form a rough preliminary
definition of health by saying that it means the absence of all these states.
Now the health of society involves among other things, that right is done by
the individuals composing it. And certain social diseases consist in a wrong
direction of the conscience. Hence the determination of abstract right
depends on the study of healthy and diseased states of society. How much
light can be got for this end from the historical records we possess? A very
great deal, if, as I believe, for ethical purposes the nature of man and of
society may be taken as approximately constant during the few thousand
years of which we have distinct records.
The matters of fact on which rational ethic must be founded are the laws of
modification of character, and the evidence of history as to those kinds of
character which have most aided the improvement of the race. For although
the moral sense is intuitive, it must for the future be directed by our
conscious discovery of the tribal purpose which it serves.
II. RIGHT AND WRONG:
THE SCIENTIFIC GROUND OF THEIR
DISTINCTION.1
The questions which are here to be considered are especially and peculiarly
everybody’s questions. It is not everybody’s business to be an engineer, or a
doctor, or a carpenter, or a soldier; but it is everybody’s business to be a
citizen. The doctrines and precepts which guide the practice of the good
engineer are of interest to him who uses them and to those whose business
it is to investigate them by mechanical science; the rest of us neither obey
nor disobey them. But the doctrines and precepts of morality, which guide
the practice of the good citizen, are of interest to all; they must be either
obeyed or disobeyed by every human being who is not hopelessly and
forever separated from the rest of mankind. No one can say, therefore, that
in this inquiry we are not minding our own business, that we are meddling
with other men’s affairs. We are in fact studying the principles of our
profession, so far as we are able; a necessary thing for every man who
wishes to do good work in it.
Along with the character of universal interest which belongs to our subject
there goes another. What is everybody’s practical business is also to a large
extent what everybody knows; and it may be reasonably expected that a
discourse about Right and Wrong will be full of platitudes and truisms. The
expectation is a just one. The considerations I have to offer are of the very
oldest and the very simplest commonplace and common sense; and no one
can be more astonished than I am that there should be any reason to speak
of them at all. But there is reason to speak of them, because platitudes are
not all of one kind. Some platitudes have a definite meaning and a practical
application, and are established by the uniform and long-continued
experience of all people. Other platitudes, having no definite meaning and
no practical application, seem not to be worth anybody’s while to test; and
these are quite sufficiently established by mere assertion, if it is audacious
enough to begin with and persistent enough afterward. It is in order to
distinguish these two kinds of platitude from one another, and to make sure
that those which we retain form a body of doctrine consistent with itself and
with the rest of our beliefs, that we undertake this examination of obvious
and widespread principles.
We say that it is wrong to murder, to steal, to tell lies, and that it is right to
take care of our families. When we say in this sense that one action is right
and another wrong, we have a certain feeling toward the action which is
peculiar and not quite like any other feeling. It is clearly a feeling toward
the action and not toward the man who does it; because we speak of hating
the sin and loving the sinner. We might reasonably dislike a man whom we
knew or suspected to be a murderer, because of the natural fear that he
might murder us; and we might like our own parents for taking care of us.
But everybody knows that these feelings are something quite different from
the feeling which condemns murder as a wrong thing, and approves
parental care as a right thing. I say nothing here about the possibility of
analyzing this feeling, or proving that it arises by combination of other
feelings; all I want to notice is that it is as distinct and recognizable as the
feeling of pleasure in a sweet taste or of displeasure at a toothache. In
speaking of right and wrong, we speak of qualities of action which arouse
definite feelings that everybody knows and recognizes. It is not necessary,
then, to give a definition at the outset; we are going to use familiar terms
which have a definite meaning in the same sense in which everybody uses
them. We may ultimately come to something like a definition; but what we
have to do first is to collect the facts and see what can be made of them, just
as if we were going to talk about limestone, or parents and children, or fuel.
It is easy to conceive that murder and theft and neglect of the young might
be considered wrong in a very simple state of society. But we find at present
that the condemnation of these actions does not stand alone; it goes with the
condemnation of a great number of other actions which seem to be included
with the obviously criminal action, in a sort of general rule. The wrongness
of murder, for example, belongs in a less degree to any form of bodily
injury that one man may inflict on another; and it is even extended so as to
include injuries to his reputation or his feelings. I make these more refined
precepts follow in the train of the more obvious and rough ones, because
this appears to have been the traditional order of their establishment. ‘He
that makes his neighbor blush in public,’ says the Mishna, ‘is as if he had
shed his blood.’ In the same way the rough condemnation of stealing carries
with it a condemnation of more refined forms of dishonesty: we do not
hesitate to say that it is wrong for a tradesman to adulterate his goods, or for
a laborer to scamp his work. We not only say that it is wrong to tell lies, but
that it is wrong to deceive in other more ingenious ways; wrong to use
words so that they shall have one sense to some people and another sense to
other people; wrong to suppress the truth when that suppression leads to
false belief in others. And again, the duty of parents toward their children is
seen to be a special case of a very large and varied class of duties toward
that great family to which we belong—to the fatherland and them that dwell
therein. The word duty which I have here used, has as definite a sense to the
general mind as the words right and wrong; we say that it is right to do our
duty, and wrong to neglect it. These duties to the community serve in our
minds to explain and define our duties to individuals. It is wrong to kill any
one; unless we are an executioner, when it may be our duty to kill a
criminal; or a soldier, when it may be our duty to kill the enemy of our
country; and in general it is wrong to injure any man in any way in our
private capacity and for our own sakes. Thus if a man injures us, it is only
right to retaliate on behalf of other men. Of two men in a desert island, if
one takes away the other’s cloak, it may or may not be right for the other to
let him have his coat also; but if a man takes away my cloak while we both
live in society, it is my duty to use such means as I can to prevent him from
taking away other people’s cloaks. Observe that I am endeavoring to
describe the facts of the moral feelings of Englishmen, such as they are
now.
Two other words are used in this connection which it seems necessary to
mention. When we regard an action as right or wrong for ourselves, this
feeling about the action impels us to do it or not to do it, as the case may be.
We may say that the moral sense acts in this case as a motive; meaning by
moral sense only the feeling in regard to an action which is considered as
right or wrong, and by motive something which impels us to act. Of course
there may be other motives at work at the same time, and it does not at all
follow that we shall do the right action or abstain from the wrong one. This
we all know to our cost. But still our feeling about the rightness or
wrongness of an action does operate as a motive when we think of the
action as being done by us; and when so operating it is called conscience. I
have nothing to do at present with the questions about conscience, whether
it is a result of education, whether it can be explained by self-love, and so
forth; I am only concerned in describing well-known facts, and in getting as
clear as I can about the meaning of well-known words. Conscience, then, is
the whole aggregate of our feelings about actions as being right or wrong,
regarded as tending to make us do the right actions and avoid the wrong
ones. We also say sometimes, in answer to the question, ‘How do you know
that this is right or wrong?’ ‘My conscience tells me so.’ And this way of
speaking is quite analogous to other expressions of the same form; thus if I
put my hand into water, and you ask me how I know that it is hot, I might
say, ‘My feeling of warmth tells me so.’
We can now, I suppose, understand one another pretty clearly in using the
words right and wrong, conscience, responsibility; and we have made a
rapid survey of the facts of the case in our own country at the present time.
Of course I do not pretend that this survey in any way approaches to
completeness; but it will supply us at least with enough facts to enable us to
deal always with concrete examples instead of remaining in generalities;
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
textbookfull.com