100% found this document useful (2 votes)
26 views

(Ebook) PHP for the Web by Larry Ullman ISBN 9780321442499, 0321442490 download

The document provides information about various PHP-related ebooks by Larry Ullman and others, including links for downloading them. It highlights titles such as 'PHP for the Web,' 'PHP and MySQL for Dynamic Web Sites,' and 'PHP 8 for Absolute Beginners.' Additionally, it includes details about the Visual QuickStart Guide for PHP, its contents, and acknowledgments.

Uploaded by

tacircaple
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
26 views

(Ebook) PHP for the Web by Larry Ullman ISBN 9780321442499, 0321442490 download

The document provides information about various PHP-related ebooks by Larry Ullman and others, including links for downloading them. It highlights titles such as 'PHP for the Web,' 'PHP and MySQL for Dynamic Web Sites,' and 'PHP 8 for Absolute Beginners.' Additionally, it includes details about the Visual QuickStart Guide for PHP, its contents, and acknowledgments.

Uploaded by

tacircaple
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 50

(Ebook) PHP for the Web by Larry Ullman ISBN

9780321442499, 0321442490 download

https://ebooknice.com/product/php-for-the-web-1206526

Explore and download more ebooks at ebooknice.com


Here are some recommended products that we believe you will be
interested in. You can click the link to download.

(Ebook) PHP for the Web: Visual QuickStart Guide by Larry Ullman ISBN
9780321733450, 0321733452

https://ebooknice.com/product/php-for-the-web-visual-quickstart-
guide-2269362

(Ebook) PHP for the Web Visual QuickStart Guide by Larry Ullman ISBN
9780134291253, 0134291255

https://ebooknice.com/product/php-for-the-web-visual-quickstart-
guide-5594918

(Ebook) PHP and MySQL for Dynamic Web Sites by Ullman, Larry E ISBN
9780134301846, 0134301846

https://ebooknice.com/product/php-and-mysql-for-dynamic-web-
sites-12033996

(Ebook) PHP 5 Advanced: Visual QuickPro Guide by Larry Ullman ISBN


9780321376015, 0321376013

https://ebooknice.com/product/php-5-advanced-visual-quickpro-
guide-983630
(Ebook) PHP Web Services: APIs for the Modern Web by Lorna Jane
Mitchell ISBN 9781491933091, 1491933097

https://ebooknice.com/product/php-web-services-apis-for-the-modern-
web-5313274

(Ebook) Mac OS X Tiger Timesaving Techniques For Dummies by Larry


Ullman, Marc Liyanage ISBN 9780764579639, 0764579630

https://ebooknice.com/product/mac-os-x-tiger-timesaving-techniques-
for-dummies-4643376

(Ebook) MySQL: Learn MySQL the Quick and Easy Way by Ullman, Larry
ISBN 9780321375735, 0321375734

https://ebooknice.com/product/mysql-learn-mysql-the-quick-and-easy-
way-22020606

(Ebook) Integrating Web Services with OAuth and PHP: A php[architect]


Guide by Matthew Frost ISBN 9781940111261, 1940111269

https://ebooknice.com/product/integrating-web-services-with-oauth-and-
php-a-php-architect-guide-6770040

(Ebook) PHP 8 for Absolute Beginners: Basic Web Site and Web
Application Development by Jason Lengstorf, Thomas Blom Hansen, Steve
Prettyman ISBN 9781484282045, 1484282043

https://ebooknice.com/product/php-8-for-absolute-beginners-basic-web-
site-and-web-application-development-46295522
VISUAL QUICKstart GUIDE

php
for THE Web
Third Edition

Larry Ullman

Peachpit Press
Visual QuickStart Guide
PHP for the Web, Third Edition
Larry Ullman

Peachpit Press
1249 Eighth Street
Berkeley, CA 94710
510/524-2178
510/524-2221 ( fax)
Find us on the Web at www.peachpit.com.
To report errors, please send a note to errata@peachpit.com.
Peachpit Press is a division of Pearson Education.
Copyright © 2009 by Larry Ullman
Editor: Rebecca Gulick
Copy Editor: Bob Campbell
Production Coordinator: Myrna Vladic
Compositor: Debbie Roberti
Indexer: Julie Bess
Cover design: Peachpit Press

Notice of Rights
All rights reserved. No part of this book may be reproduced or transmitted in any form by any means, electronic,
mechanical, photocopying, recording, or otherwise, without the prior written permission of the publisher. For
information on getting permission for reprints and excerpts, contact permissions@peachpit.com.

Notice of Liability
The information in this book is distributed on an “As Is” basis, without warranty. While every precaution has
been taken in the preparation of the book, neither the author nor Peachpit Press shall have any liability to any
person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the
instructions contained in this book or by the computer software and hardware products described in it.

Trademarks
Visual QuickStart Guide is a registered trademark of Peachpit Press, a division of Pearson Education. Macintosh
and Mac OS X are registered trademarks of Apple Computer, Inc. Microsoft and Windows are registered
trademarks of Microsoft Corp. Other product names used in this book may be trademarks of their own
respective owners. Images of Web sites in this book are copyrighted by the original holders and are used with
their kind permission. This book is not officially endorsed by nor affiliated with any of the above companies.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as
trademarks. Where those designations appear in this book, and Peachpit was aware of a trademark claim,
the designations appear as requested by the owner of the trademark. All other product names and services
identified throughout this book are used in editorial fashion only and for the benefit of such companies with
no intention of infringement of the trademark. No such use, or the use of any trade name, is intended to
convey endorsement or other affiliation with this book.
ISBN 13: 978-0-321-44249-9
ISBN 10: 0-321-44249-0
987654321
Printed and bound in the United States of America
For Jessica, Gina, and Rich,
with gratitude for all of their
love and support.
Special thanks
Many, many thanks to everyone at Peachpit
Press for their assistance and hard work,
especially:
The best darn editor in the world, Rebecca
Gulick. Thanks for, well, just about every-
thing. As always, it’s my pleasure to be able
to work with you.
Bob Campbell, for his attention to detail.
Deb Roberti and Myrna Vladic, who take a
bunch of disparate stuff and turn it into a
book. Julie Bess for her excellent indexing.
Everyone at Peachpit for doing what’s
required to create, publish, distribute,
market, sell, and support these books.
My sincerest thanks to the readers of the
other editions of this book and my other
books. Thanks for your feedback and
support and for keeping me in business.
Finally, thanks to: Rasmus Lerdorf (who got
the PHP ball rolling); the people at PHP.net
and Zend.com; those who frequent the vari-
ous newsgroups and mailing lists; and the
greater PHP and open source communities
for developing, improving upon, and support-
ing such wonderfully useful technology.
Table of Contents
Introduction ix
Chapter 1: Getting Started with PHP 1
Basic XHTML Syntax. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Basic PHP Syntax. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Testing Your Script. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Sending Text to the Browser . . . . . . . . . . . . . . . . . . . . . 16

Table of Contents
Sending HTML to the Browser. . . . . . . . . . . . . . . . . . . 20
Using White Space. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Adding Comments to Scripts. . . . . . . . . . . . . . . . . . . . 25
Basic Debugging Steps. . . . . . . . . . . . . . . . . . . . . . . . . . . 28

Chapter 2: Variables 31
What Are Variables?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Variable Syntax. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Types of Variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Assigning Values to Variables . . . . . . . . . . . . . . . . . . . . 41
Understanding Quotation Marks. . . . . . . . . . . . . . . . . 44

Chapter 3: HTML Forms and PHP 47


Creating a Simple Form. . . . . . . . . . . . . . . . . . . . . . . . . . 48
Using GET or POST. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Receiving Form Data in PHP. . . . . . . . . . . . . . . . . . . . . 54
Displaying Errors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Error Reporting. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Manually Sending Data to a Page. . . . . . . . . . . . . . . . . 65

Chapter 4: Using Numbers 71


Creating the Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
Performing Arithmetic. . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Formatting Numbers. . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
Understanding Precedence . . . . . . . . . . . . . . . . . . . . . . 82
Incrementing and Decrementing a Number. . . . . . 84
Creating Random Numbers. . . . . . . . . . . . . . . . . . . . . . 86

v
Table of Contents

Chapter 5: Using Strings 89


Creating the HTML Form. . . . . . . . . . . . . . . . . . . . . . . . 90
Connecting Strings (Concatenation) . . . . . . . . . . . . . 93
Handling Newlines. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
HTML and PHP. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
Encoding and Decoding Strings. . . . . . . . . . . . . . . . 103
Finding Substrings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Replacing Parts of a String . . . . . . . . . . . . . . . . . . . . . 112

Chapter 6: Control Structures 115


Creating the HTML Form. . . . . . . . . . . . . . . . . . . . . . 116
The if Conditional. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
Validation Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . 124
Using else. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
More Operators. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
Using elseif. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
Table of Contents

The Switch Conditional. . . . . . . . . . . . . . . . . . . . . . . . 142


The for Loop. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146

Chapter 7: Using Arrays 151


What Is an Array?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
Creating an Array. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
Adding Items to an Array . . . . . . . . . . . . . . . . . . . . . . 158
Accessing Array Elements. . . . . . . . . . . . . . . . . . . . . . 161
Creating Multidimensional Arrays. . . . . . . . . . . . . . 165
Sorting Arrays. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
Transforming Between Strings and Arrays. . . . . . 174
Creating an Array from a Form. . . . . . . . . . . . . . . . . 179

Chapter 8: Creating Web Applications 185


Creating Templates. . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
Using External Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
Using Constants. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
Working with the Date and Time. . . . . . . . . . . . . . . 205
Handling HTML Forms with PHP, Revisited . . . . 208
Making Forms Sticky. . . . . . . . . . . . . . . . . . . . . . . . . . . 214
Sending Email. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
Output Buffering. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
Manipulating HTTP Headers. . . . . . . . . . . . . . . . . . . 231

vi
Table of Contents

Chapter 9: Cookies and Sessions 237


What Are Cookies? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238
Creating Cookies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
Reading from Cookies. . . . . . . . . . . . . . . . . . . . . . . . . . 248
Adding Parameters to a Cookie . . . . . . . . . . . . . . . . 254
Deleting a Cookie. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
What Are Sessions?. . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
Creating a Session . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
Accessing Session Variables. . . . . . . . . . . . . . . . . . . . 267
Deleting a Session . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269

Chapter 10: Creating Functions 271


Creating and Using Simple Functions . . . . . . . . . . 272
Creating and Calling Functions
That Take Arguments. . . . . . . . . . . . . . . . . . . . . . 279
Setting Default Argument Values. . . . . . . . . . . . . . . 283

Table of Contents
Creating and Using Functions That
Return a Value . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
Understanding Variable Scope. . . . . . . . . . . . . . . . . 291

Chapter 11: Files and Directories 297


File Permissions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
Writing to Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
Locking Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311
Reading from Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
Handling File Uploads . . . . . . . . . . . . . . . . . . . . . . . . . 317
Navigating Directories. . . . . . . . . . . . . . . . . . . . . . . . . 325
Creating Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . 331
Reading Files Incrementally. . . . . . . . . . . . . . . . . . . . 339

Chapter 12: Intro to Databases 345


Introduction to SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . 346
Connecting to MySQL . . . . . . . . . . . . . . . . . . . . . . . . . 348
MySQL Error Handling. . . . . . . . . . . . . . . . . . . . . . . . . 352
Creating and Selecting a Database . . . . . . . . . . . . . 355
Creating a Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358
Inserting Data into a Database. . . . . . . . . . . . . . . . . 363
Securing Query Data. . . . . . . . . . . . . . . . . . . . . . . . . . . 368
Retrieving Data from a Database. . . . . . . . . . . . . . . 371
Deleting Data in a Database. . . . . . . . . . . . . . . . . . . . 377
Updating Data in a Database. . . . . . . . . . . . . . . . . . . 383

vii
Table of Contents

Chapter 13: Regular Expressions 391


What Are Regular Expressions?. . . . . . . . . . . . . . . . 392
Matching Patterns. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 394
Using Literals. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399
Using Metacharacters. . . . . . . . . . . . . . . . . . . . . . . . . . 400
Using Quantifiers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402
Using Classes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404
Matching and Replacing Patterns. . . . . . . . . . . . . . 406

Appendix A: Installation and Configuration 411


Installation on Windows. . . . . . . . . . . . . . . . . . . . . . . 412
Installation on Mac OS X. . . . . . . . . . . . . . . . . . . . . . . 415
Using the MySQL Client. . . . . . . . . . . . . . . . . . . . . . . . 419
Creating MySQL Users. . . . . . . . . . . . . . . . . . . . . . . . . 422
PHP Configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428

Appendix B: Resources and Next Steps 431


Table of Contents

Online PHP Resources. . . . . . . . . . . . . . . . . . . . . . . . . 432


Database Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . 435
Top Ten Frequently Asked
Questions (or Problems). . . . . . . . . . . . . . . . . . . 436
Next Steps. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440
Tables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442

Index 445

viii
Introduction
i
When I began the first edition of this book,

Introduction
back in the year 2000, PHP was a little-known
open source project. It was adored by techni-
cal people in the know but not yet recognized
as the popular choice for Web development
that it is today. When I taught myself PHP,
very little documentation was available on
the language—and that was my motivation
for writing this book in the first place.
Today things are different. The Internet has
gone through a boom and a bust and has
righted itself. Furthermore, PHP is now the
reigning king of dynamic Web design tools
and has begun to expand beyond the realm
of Web development. But despite PHP’s
popularity and the increase in available
documentation, sample code, and examples,
a good book discussing the language is still
relevant. Particularly as PHP makes its sixth
major release, a book such as this—which
teaches the language in simple but practical
terms—can be your best guide in learning the
information you need to know.
This book will teach you PHP, providing
both a solid understanding of the fundamen-
tals and a sense of where to look for more
advanced information. Although it isn’t a
comprehensive programming reference,
through demonstrations and real-world
examples, this book provides the knowledge
you need to begin building dynamic Web
sites and Web applications using PHP.

ix
Introduction

What Is PHP?
PHP originally stood for Personal Home
Page. It was created in 1994 by Rasmus
Lerdorf to track the visitors to his online
résumé. As its usefulness and capabilities
grew (and as it began to be utilized in more
professional situations), PHP came to mean
PHP: Hypertext Preprocessor. (The defini-
tion basically means that PHP handles data
before it becomes HTML—which stands
for Hypertext Markup Language.) Figure i.1 At the time of this writing, this is the
appearance of the official PHP Web site, located at
According to the official PHP Web site, found www.php.net. Naturally, this should be the first place
at www.php.net (Figure i.1), PHP is an HTML you look to address most of your PHP questions
What Is PHP?

embedded scripting language. I’ll explain this and curiosities.


definition in more detail.
To say that PHP is HTML embedded means
that it can be written within your HTML
code—HTML being the code with which all
Web pages are built. Therefore, programming
with PHP starts off as only slightly more com-
plicated than hand-coding HTML.
Also, PHP is a scripting language, as opposed
to a programming language. This means that
PHP is designed to do something only after
an event occurs—for example, when a user
submits a form or goes to a URL (Uniform
Resource Locator—the technical term for
a Web address). Conversely, programming
languages such as Java and C can be used to
write stand-alone applications, which may or
may not involve the Web. The most popular
example of a scripting language is JavaScript,
which commonly handles events that occur
within the Web browser. Another way to refer
to the different types of languages is to use
the term interpreted for languages such as
PHP and JavaScript, which can’t act on their
own, and compiled for those like C and Java,
which can.

x
Introduction

You should also understand that PHP is a


server-side technology. This refers to the
fact that everything PHP does occurs on the
server (as opposed to on the client, which is
the computer being used by the person view-
ing the Web site). A server is just a computer
set up to provide the pages you see when you
go to a Web address with your browser ( for
example, Firefox, Microsoft Internet Explorer,
or Safari). I’ll discuss this process in more
detail later (see “How PHP Works”).
Finally, PHP is cross-platform, meaning
that it can be used on machines running
Unix, Windows, Macintosh, and other oper-

What Is PHP?
ating systems. Again, we’re talking about the
server’s operating system, not the client’s.
Not only can PHP run on almost any operat-
What PHP Is Not ing system, but, unlike most other program-
The thing about PHP that confuses ming languages, it enables you to switch your
most new learners is what PHP can’t do. work from one platform to another with few
Although you can use the language for an or no modifications.
amazing array of tasks, its main limitation At the time this book was written, PHP
is that PHP cannot be used for client-side was simultaneously in versions 4.4.9 and
features found in some Web sites. 5.2.6. (The 5.x branch has not yet been
Using a client-side technology like universally adapted, so the older version is
JavaScript, you can create a new browser still being maintained for any major security
window, add mouseovers, make pop-up concerns.) This book was actually tested
alerts, resize the browser window, find using a development version of PHP 6, the
out the screen size on the user’s machine, next major release of the language (it’s release
and dynamically generate and alter forms. date is not known at the time of this writ-
None of these tasks can be accomplished ing). The primary change in PHP 6—and it’s a
using PHP (because PHP is server-side, big one—is support for Unicode. Unicode, in
whereas those are client-side issues). But, short, provides a way to represent every char-
you can use PHP to create JavaScript, just acter from every language. Thus, in PHP 6,
as you can use PHP to create HTML. you can handle strings in any language; even
variable and function names can be written
When it comes time to develop your own in any language.
PHP projects, remember that you can
only use PHP to send information (HTML
and such) to the Web browser. You can’t
do anything else within the Web browser
until another request from the server has
been made (a form has been submitted or
a link has been clicked).

xi
Introduction

The other significant change in PHP 6 is the


removal of several outdated features. Every
removed feature has been disabled in PHP’s
default configuration for some time, and
although you could enable it, the recommen-
dation was not to use it at all. In PHP 6, you
won’t have the choice.
Although this book was written using a
development version of PHP 6, all of the code
is backward compatible, at least to PHP ver-
sion 5.x, if not to 4.x. In a couple of situations
where you might still have and be using a Figure i.2 This is the home page of Zend, creators
of the programming at the heart of PHP. The site
feature that will be removed in PHP 6, a note contains much useful software as well as a code
in a sidebar or a tip will indicate how you can gallery and well-written tutorials.
What Is PHP?

adjust the code accordingly.


More information can be found at PHP.net
and www.zend.com, the minds behind the core
of PHP (Figure i.2).

xii
Introduction

Why Use PHP?


Put simply, PHP is better, faster, and easier
to learn than the alternatives. All Web sites
must begin with just HTML, so you can
create an entire site using a number of static
HTML pages. But basic HTML is a limited
approach that does not allow for flexibility
or responsiveness. Visitors accessing HTML
pages see simple pages with no level of cus-
tomization or dynamic behavior. With PHP,
you can create exciting and original pages
based on whatever factors you want to con-
sider. PHP can also interact with databases

Why Use PHP?


and files, handle email, and do many other
things that HTML can’t.
Webmasters learned a long time ago that
HTML alone won’t produce enticing and last-
ing Web sites. Toward this end, server-side
technologies such as PHP have become the
norm. These technologies allow Web-page
designers to create Web applications that are
dynamically generated, taking into account
whichever elements the programmer desires.
Often database-driven, these advanced sites
can be updated and maintained more readily
than static HTML pages.
When it comes to choosing a server-side
technology, the primary alternatives to PHP
are CGI scripts (Common Gateway Interface,
commonly, but not necessarily written in
Perl), ASP.NET (Active Server Pages), Adobe’s
ColdFusion, JSP (JavaServer Pages), and Ruby
on Rails. JavaScript isn’t truly an alternative
to PHP (or vice versa) because JavaScript is
a client-side technology and can’t be used
to create HTML pages the same way PHP or
these others can.

xiii
Introduction

So the question is, why should a Web


designer use PHP instead of CGI, ASP.NET,
JSP, or whatever to make a dynamic Web site?
 PHP is much easier to learn and use.
People—perhaps like you—without
any formal programming training can
write PHP scripts with ease after reading
this one book. In comparison, ASP.NET
requires an understanding of VBScript,
C#, or another language; and CGI requires
Perl (or C). These are more complete
languages and are much more difficult
to learn.
Why Use PHP?

 PHP was written specifically for


dynamic Web page creation. Perl (and Figure i.3 Netcraft’s (www.netcraft.com) graphic
shows PHP’s phenomenal growth since 2000.
VBScript and Java) were not, and this fact
suggests that, by its very intent, PHP can
do certain tasks faster and more easily
than the alternatives. I’d like to make it
clear, however, that although I’m suggest-
ing PHP is better for certain things (specifi-
cally those it was created to do), PHP isn’t a
better programming language than Java or
Perl—they can do things PHP can’t.
 PHP is both free and cross-platform.
So, you can learn and use it on nearly any
computer and incur no cost. Furthermore,
its open source nature means that PHP’s
users are driving its development, not
some corporate entity.
 PHP is the most popular tool available
for developing dynamic Web sites. At
the time of this writing, PHP is in use on
over 20 million domain names (Figure i.3).
By mastering this technology, you’ll pro-
vide yourself with either a usable hobby
or a lucrative skill.

xiv
Introduction

How PHP Works


PHP is a server-side language, which means
the code you write in PHP resides on a host
computer that serves Web pages to Web
browsers. When you go to a Web site (www.
DMCinsights.com, for example), your Internet
service provider (ISP) directs your request to
the server that holds the www.DMCinsights.
com information. The server reads the PHP
code and processes it according to its
scripted directions. In this example, the PHP
code tells the server to send the appropriate
Web page data to your browser in the form of

How PHP Works


HTML (Figure i.4). In short, PHP creates an
HTML page on the fly based on parameters
of your choosing.

Figure i.4 This graphic demonstrates (albeit in very simplistic terms) how the process works between a client, the
server, and a PHP module (an application added to the server to increase its functionality) to send HTML back to the
browser. All server-side technologies use a third-party module on the server to process the data that’s sent back to
the client.

xv
Introduction

This differs from an HTML-generated site


in that when a request is made, the server
merely sends the HTML data to the Web
browser—no server-side interpretation
occurs (Figure i.5). Hence, to the end user’s
browser, there may or may not be an obvi-
ous difference between what home.html and
home.php look like, but how you arrive at that
point is critically altered. The major differ-
ence is that by using PHP, you can have the
server dynamically generate the HTML code.
For example, different information could
be presented if it’s Monday as opposed to
Tuesday or if the user has visited the page
How PHP Works

before. Dynamic Web page creation sets


apart the less appealing, static sites from the
more interesting and, therefore, more visited,
interactive ones.
The central difference between using PHP
and using straight HTML is that PHP does
everything on the server and then sends the
appropriate information to the browser. This
book covers how to use PHP to send the right
data to the browser.

Figure i.5 Compare this direct relationship of how a server works with basic HTML to that of Figure i.4. This is also
why HTML pages can be viewed in your browser from your own computer—they don’t need to be “served,” but
dynamically generated pages need to be accessed through a server that handles the processing.

xvi
Introduction

What You’ll Need


The most important requirement for working
with PHP—because it’s a server-side scripting
language—is access to a PHP-enabled server.
Considering PHP’s popularity, your ISP or Web
host most likely has this option available to
you on their servers. You’ll need to contact
them to see what technology they support.
Your other option is to install PHP and a
Web server application (like Apache) on your
own computer. Users of Windows, Mac OS
Figure i.6 The popular Dreamweaver IDE supports X, or Linux can easily install and use PHP

What You’ll Need


PHP development, among other server-side for no cost. Directions for installing PHP are
technologies. available in Appendix A, “Installation and
Configuration.” If you’re up to the task of
using your own PHP-installed server, you can
take some consolation in knowing that PHP
is available for free from the PHP Web site
(www.php.net) and comes in easy-to-install
packages. If you take this approach, and I
recommend that you do, then your computer
will act as both the client and the server.
The second requirement is almost a
given: You must have a text editor on your
computer. Crimson Editor, WordPad,
TextWrangler, and similar freeware applica-
tions are all sufficient for your purposes; and
BBEdit, EditPad, TextMate, and other com-
mercial applications offer more features that
you may appreciate. If you’re accustomed to
using a graphical interface (also referred to as
WYSIWYG—What You See Is What You Get)
like Adobe Dreamweaver (Figure i.6), you
can consult that application’s manual to see
how to program within it. For help in finding
a good PHP-capable editor, head to http://
www.dmcinsights.com/links/1.

xvii
Introduction

Third, you need a method of getting the


scripts you write in your text editor to the
server. If you’ve installed PHP on your own
computer, you can save the scripts to the
appropriate directory. However, if you’re
using a remote server with your ISP or
Web host, you’ll need an FTP (File Transfer
Protocol) program to send the script to
the server. There are plenty of FTP appli-
cations available; in Chapter 1, “Getting
Started with PHP,” I use the free FileZilla
(www.filezilla-project.org, Figure i.7)
for an example.
What You’ll Need

Finally, if you want to follow the examples Figure i.7 The FileZilla application can be used on
in Chapter 12, “Introduction to Databases,” many different operating systems to move PHP
scripts and other files to a remote server.
you need access to MySQL (www.mysql.com,
Figure i.8) or another database application.
MySQL is available in a free version that you
can install on your own computer.
This book assumes only a basic knowledge
of HTML, although the more comfortable
you are handling raw HTML code without
the aid of a Web-creation application such
as Dreamweaver, the easier the transition to
using PHP will be. Every programmer will
eventually turn to an HTML reference at
some time or other, regardless of how much
you know, so I encourage you to keep a good
HTML book by your side. One such introduc-
tion to HTML coding is Elizabeth Castro’s Figure i.8 MySQL’s Web site (at the time of this writing).
HTML for the World Wide Web with XHTML
and CSS: Visual QuickStart Guide (Peachpit
Press, 2002).
Previous programming experience is cer-
tainly not required. However, it may expedite
your learning, because you’ll quickly see
numerous similarities between, for example,
Perl and PHP or JavaScript and PHP.

xviii
Introduction

Script i.1 A sample PHP script, with line numbers and


bold emphasis on a specific section of code. About This Book
This book attempts to convey the fundamen-
1 <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML tals of programming with PHP while hinting
1.0 Transitional//EN” at some of the more advanced features you
2 “http://www.w3.org/TR/xhtml1/DTD/ may want to consider in the future, without
xhtml1-transitional.dtd”> going into overwhelming detail. It uses the
3 <html xmlns=”http://www.w3.org/1999/ following conventions to do so.
xhtml” xml:lang=”en” lang=”en”>
4 <head> The step-by-step instructions indicate what
5 <meta http-equiv=”Content-Type” coding you’re to add to your scripts and
content=”text/html; charset=utf-8”/> where. The specific text you should type is
6 <title>Hello, World!</title> printed in a unique type style to separate it
7 </head> from the main body text. For example:

About This Book


8 <body>
<?php print “Hello, World!”; ?>
9 <?php print “Hello, World!”; ?>
10 </body> The PHP code is also written as its own
11 </html> complete script and is numbered by line for
reference (Script i.1). You shouldn’t insert
these numbers yourself, because doing so will
render your work inoperable. I recommend
using a text editor that automatically displays
the line numbers for you—the numbers will
What’s New in This Book? help when you’re debugging your work. In the
scripts you’ll sometimes see particular lines
I would consider this third edition to be a highlighted in bold, in order to draw atten-
relatively light revision of an already solid tion to new or relevant material.
book. When the second edition was writ-
ten, PHP was at version 4.x, with version
5 in development. Now version 5 is out
and version 6 is in development. The most
significant changes in PHP 5 affect more
advanced topics than are covered here.
The most significant changes in PHP 6 are
support for Unicode and the removal of
some features.
With that in mind, the first wave of altera-
tions in this edition are the removal of a
few topics that no longer apply to PHP
6. Second, I updated all the examples
to make use of Unicode and the UTF-8
encoding (if you don’t know what this
means, see Chapter 1). Third, I tweaked
some of the examples mostly to satisfy my
own drive for perfection.

xix
Exploring the Variety of Random
Documents with Different Content
三個,莫非是日前見的不成?若果然是,只要弄得一個上手,那兩個
自然會來,何須要他幫助?就回復道:“豈有此理!只要有一個也就夠
得緊了,怎敢做那貪得無厭之事!”賽崑崙道:“這等才好。我且問
你,你還是喜肥的還是喜瘦的?”未央生道:“婦人家的身體肥有肥的
妙處,瘦有瘦的妙處。但是肥不可勝衣,瘦不可露骨。只要肥瘦得宜
就好了。”賽崑崙道:“這等說來三個都合著你意思。我再問你,你還
是喜風流的喜老實的?”未央生道:“自然是風流的好。老實婦人睡在
身邊,一些興趣也沒有,倒不如獨宿的干淨。”賽崑崙搖頭道:“這等
說來,三個都不是你的對頭。”未央生道:“怎見得那婦人老實?”賽崑
崙道:“那三個婦人皆是一般家數,若論姿色,倒有十二分,只是'風
流'二字不十分在行。”未央生道:“這個不妨。婦人家的風情態度可以
教導得來。不瞞長兄說,弟婦初來的時節也是個老實頭,被小弟用幾
日工夫把她淘熔出來,如今竟風流不過了。只要那三個婦人姿色好,
就老實些小弟自有變化之法。”

賽崑崙道:“這也罷了。我再問你,你還是一見了面就要到手,還是
肯熬幾月工夫,慢慢伺候到手?”未央生道:“不瞞長兄說,小弟平日
慾火極盛,三五夜不同婦人睡就要夢遺。如今離家日久,這點欲心慌
得緊了。遇不著標致女子還可以勉強支持,若遇著了,只怕就涵養不
住了。”賽崑崙道:“這等,丟了那兩個,單說這一個罷。那兩個是富
貴人家女子,一時難到手。這一個是窮漢老婆,容易設法。我因許你
這樁事,時時刻刻放在心頭,遇了婦人定要仔細看看。那一日,偶從
街上走過,看見這個婦人坐在門裡,門外掛著一條竹簾。雖然隔著簾
子看不明白,只覺得面龐之上紅光灼灼,白焰騰騰,竟像珍珠寶貝,
有一段光芒從裡面射出來一般。再看她渾身態度,只像一幅美人圖掛
在簾子裡面隨風吹動一般。我走過去那門對面立了一會,只見一個男
子從裡面出來,生得粗粗笨笨,衣服襤褸,背一捆絲到市上去賣。我
就去問他,鄰居說他姓權,為人老實,人就因此叫他做'權老實'。那婦
人就是他妻子。
“我恐隔著簾子看不仔細,過了幾日又從門首經過。她又坐在裡面。
我心生一計,掀開簾子闖進去,只說尋她丈夫買絲。她說男人不在
家,若要買絲家裡盡有,取出來看就是。說罷回身取絲出來。我見她
十個指頭就如藕芽一般,一雙小腳還沒有三寸。手腳雖然看見了,還
有身上的肌肉不能看見,未知黑白何如。我又生個法子,見她架子頂
上還有一捆絲,就對他道:'這些都不好。那架子頂上的拿來看看何
如?'她答應了,就擎起手臂來去拿。你曉得,此時熱天,她身上穿的
是單紗衫子,擎起手來的時節,那兩雙大袖直褪到肩頭上面,不但一
雙手臂全然現出,連胸前的兩乳也隱隱躍躍露出些影子出來。真是雪
一般白,鏡一般光。我生平所見的婦人這就是第一了。我因勞她半
日,不好意思,只得買了一捆絲出來。請問賢弟,這婦人你是要不
要?”未央生道:“這等說來竟是個十全的了,有甚麼不要?只是這個
婦人怎麼就能勾見面,見了面就能勾到手?”賽崑崙道:“不難。我如
今就同你拿些銀子去伺候,等她丈夫出門,依舊用前面的法闖進去買
絲。你中意不中意一見就決了。我想她終日對著那個粗笨丈夫老老實
實,一些情趣也沒有。忽見了你豈不動心?你略做些勾引她的光景,
她若當面不惱,我回來就替你商量做事。管取三日之內定然到手。若
要做長遠夫妻,也都在我身上。”

未央生道:“若得如此,感恩不淺。只是一件,你既有神出鬼沒的計
較,又有飛牆走壁的神通,天下的事必沒有難做的了。為甚麼這一個
就做得來,那兩個全不說起?畢竟是窮漢好欺負,富貴人家不敢去惹
他!?”賽崑崙道:“天下事都是窮漢好欺負,富貴人家難惹,只有偷
婦人一節,倒是富貴人家好欺負,窮漢難惹。”未央生道:“這是何
故?”賽崑崙道:“富貴人家定有三妻四妾,丈夫睡了一個,定有幾個
守空房。自古道飽暖思淫欲。那婦人飽食暖衣,終日無聊,單單想著
這件事。到沒奈何的時節,若有男子鑽進被去,她還求之不得,豈肯
推了出來?就是丈夫走來撞見,若是要捉住送官,又怕壞了富貴體
面,若是要一齊殺死,又捨不得那樣標致婦人。婦人捨不得,豈有獨
殺姦夫之理?所以忍氣吞聲,放條生路讓他走了。那窮漢之家只有一
個妻子,夜夜同睡,莫說那婦人飢寒勞苦不起淫心,就有淫心與男子
乾事,萬一被丈夫撞見,那貧窮之人不顧體面,不是拿住送官,就是
一同殺死。所以窮漢難惹,富貴人家好欺負。”

未央生道:“既然如此,你今日所說的事又與這議論相反?”賽崑崙
道:“不是我做的事與說的話相反,只因這一個人家與那兩個人家的地
位恰好相反。所以這一家好設法,那兩個婦人難以到手。”未央生
道:“如今小弟心上已註意在這一邊了,只是那兩個婦人何妨也說一
說,等小弟知道長兄的盛意,為我這樣費心。 ”賽崑崙道:“那兩個婦
人一個有二十多歲,一個有十六七歲。她兩個在娘家是嫡堂姐妹,在
夫家又是姻親妯娌。夫家世代做官,只有她兩人的丈夫是個秀才。哥
哥叫做'臥雲生',與那二十多歲婦人做親四五年了。兄弟叫做'倚雲
生',與那十六七歲的婦人成親不上三月。兩人的姿色也與方才說的婦
人一般。只是一樣的老實,幹事的時節身也不動,口也不開,看她意
思竟像不喜幹的光景。婦人又不好淫,丈夫又沒有三妻四妾,夜夜同
睡,難以算計。你除非千方百計引動她淫心,又要嗣候她丈夫不在,
方才可以下手。這不是有幾月工夫?不如賣絲的婦人,丈夫常不在
家,容易設法。”

未央生見他說那兩個婦人與日前所見之人有些相似,心上還捨不得
丟開。又對他道:“長兄的主意雖不差,只是還有見不到處。你說那兩
個婦人老實沒有淫心,必是她丈夫本錢細微,精力短少,幹得她不快
活,所以如此。若還遇了小弟,只怕那老實的也會不老實起來。”賽崑
崙道:“我看那兩個男子本錢也不細微,精力也不短少。只是比了極粗
大長遠的稍遜他。我且問你,你的本錢有多少大?精力有幾時長?也
要見教一見教,使我知道你伎倆的深淺,好放心替你做事。 ”未央生
欣然道:“這個不勞長兄掛念,小弟的本錢精力也算得來。隨你甚麼大
量婦人,定要請她吃個醉飽,方才散席。決不像酸子請客,到把飽的
吃飢,醉的吃醒了。”賽崑崙道:“這等就好。只是略說一說也不妨,
賢弟往常與婦人幹事大約有多少提方才得洩?”未央生道:“小弟與婦
人幹事沒有甚麼規矩,隻請她吃一個無算數就罷了。那裡記得數
目。”賽崑崙道:“數目記不出,時刻是記得出的。大約耐得幾更天
氣?”原來未央生的本事只有半更,因要賽崑崙替他做事,恐怕說少了
他要藉端推諉,只得加上半更。就答應道:“小弟的力量足足支持得一
更!”塞崑崙道:“這等說來也是平常的精力,不叫做高強。若是夫婦
幹事,有這本領也就好了。若要隔家過捨去做偷菅劫寨的事,只怕不
是平等力量可以做得來的。”

未央生道:“長兄不消過慮。小弟前日買得有絕好的春方在那邊,如
今正為沒有婦人使英雄無用武之地。只要好事做得成,到臨時用些搽
抹的功夫,不怕他不久。”賽崑崙道:“春方只能使他久,不能使他
大。若是本錢粗大的,用了春方就像有才學的舉子,到臨考時吃些人
參補藥,走到場屋裡自然精神加倍,做得文字出來。那本錢微細的,
用了春方尤如腹內空虛的秀才,到臨考時就把人參補藥論斤吃下去,
走到場屋裡也只是做不出。我今只問你這物事有多少大?有幾寸
長?”未央生道:“不消說得,只還你不小就是。”賽崑崙見他不說,就
伸手去扯他的褲襠,要他脫出來看。未央生再三迴避,只是不肯。賽
崑崙道:“若是這等,劣兄絕不敢替你做事,若強替你做事,萬一不看
那婦人疼癢,被她叫喊起來,說你去強姦她怎麼了得?到那時弄出事
來倒是劣兄耽誤你了。怎麼使得?”未央生見他激切,只得陪個笑臉
道:“小弟的本錢也看得過,只是清天白日在朋友面前取出,覺得不
雅。今長兄既然過慮,小弟只得獻醜了!”就把褲帶解開,取出陽物,
把一雙手托住,對賽崑崙掂幾踮,道:“這就是小弟的微本。長兄請
看。”賽崑崙走近身去仔細一觀,只見:

本身瑩白,頭角鮮紅。根邊細草蒙茸,皮里微絲隱現。量處豈無二
寸,稱來足有三錢。十三處子能容,二七孌童最喜。臨事時身堅似
鐵,幾同絕大之□於;竣事後體曲如弓,頗類極粗之蝦米。

賽崑崙把陽物看了一會,再不則聲。未央生只說見他本錢粗大,所
以吃驚,就說道:“這是疲軟時如此,若到振作之後還有可觀。”賽崑
崙道:“疲軟時是這等,振作時也有限。請收拾罷。”說完不覺大笑
道:“賢弟為何不知分量,自家本錢沒有別人三分之一,還要去偷別人
的老婆!我起初見你各處尋婦人,只說定有絕大的傢伙帶在身邊,使
人見了害怕,所以不敢輕易借觀。那裡曉得是根肉搔頭,只好放在陰
毛里面擦癢,正經所在是用他不著。”未央生道:“不瞞長兄說,小弟
這賤具雖不甚魁偉,也曾有人喝彩過的,亦不至如此無用。”賽崑崙
道:“有人喝彩,必是未經破瓜的處女,不曾幹事的孩童,若見了他自
然要讚歎幾句。除了這兩種人,只怕就與我一樣,不肯奉承尊具
了。”未央生道:“照長兄說來,難道世上人的肉具都大似小弟的不
成?”賽崑崙道:“這件東西是劣兄常見之物,不止千餘根。從沒有第
二根像尊具這般雅緻。”

未央生道:“別人的且不要管,隻請問那三個婦人的丈夫,他腰間之
物比小弟的何如?”賽崑崙道:“比賢弟的大也大一兩倍,長也長一兩
倍。”未央生笑道:“我知道長兄的話不是真言。乃不肯替小弟任事,
藉端推諉,如今試出來了。我且問你,那兩個的或者你夜間去偷他看
見了,也不可知。這個賣絲的婦人,據你說不過日間去一次,又不曾
遇見他男子,怎麼知道他的東西比小的長大一兩倍?”賽崑崙道: “那
兩個是目見的,這一個是耳聞的。我初見之時,走去問她鄰舍,鄰舍
對我說了姓名。我又問他道:'這樣標致女子嫁了那粗蠢丈夫不知平日
相得否?'鄰舍道:'他丈夫的相貌雖然粗蠢,還虧得有一副爭氣的本
錢,所以過得日子還不十分吵鬧。'我又問道:'他的本錢有多少大?
'鄰舍道:'量便不曾替他量,只見他夏天脫了衣服那件東西在褲子裡盪
來蕩去,就像棒槌一樣,所以知道他的本錢爭氣。'我今日所以定要問
你借觀,就是為此。不然為甚麼沒原沒故藉人陽物看起來?”

未央生聽了,才曉得他是真話,有些沒趣起來。只得又對他道:“婦
人與男子相處,也不單為色欲之事,或是憐他的才,或是愛他的貌。
若是才貌不濟的,就要靠本事了。小弟這兩件都還去得,或者她看才
貌分上恕我幾分也不可知。還請長兄始終其事,不可以一短而棄所
長,把為朋友的念頭就中止了。”賽崑崙道:“ 才貌兩件是偷婦人的引
子,就如藥中的薑棗一般,不過借它氣味,把藥力引入臟腑。及至引
入之後,全要藥去治病,那薑棗都用不著了。男子偷婦人若沒有才
貌,引不得身子入門。入門之後,就要用著真本事了。難道在被窩裡
相面,肚子上做詩不成?若還本錢細微,精力有限的,就把才貌兩件
引了進去,到干事的時節一兩遭幹不中意那嬌人就要生疏了。做男子
的既然拚了性命偷著女子,也要與她心投意合相處一生半世便好。若
要只圖一兩遭快活,為甚麼費這樣心機?且不要說男子偷婦人要圖長
久快活,就是婦人瞞丈夫偷男子,也不知費多少提防,擔多少驚嚇,
指望要快活。若還一些受用也沒有,就像雌雞受雄的一般,裡面還不
曾得知就完了賬,豈不壞她一生名節?賢弟不要怪我說,都像你這樣
的本錢,這樣的精力,只要保得自家妻子不走邪路就夠了。再不可痴
心妄想,去坫污人家女子。今日還虧劣兄老到,相體裁衣,若還不顧
長短,信手做去,使衣服大似身子,豈不壞了作料?等那婦人報怨也
罷了,只怕賢弟還要怪我謀事不忠,故意尋那寬而無當的婦人來塞
責。劣兄出言粗鹵,賢弟不要見怪。 ”未央生見他言語激烈,料想好
事不成,無言可答。賽崑崙又安慰了幾句,就起身辭去。未央生興致
索然,也就送他去了。他掃興之後不知如何,直到下回是有定局。

評曰:每一番議論定有絕精的比喻,無不使人快心。如“春方乃臨場
補藥”,“才貌乃藥中引子”之類,不可勝數。雖屬諧謔之語,實有至理
存焉。我竟不知作者的心肝有幾萬幾千個孔竅,而遂玲瓏至此也。

第七回:怨生成撫陽痛哭思改正屈膝哀求

卻說未央生一團高興,被賽崑崙說得冰冷,就像死人一般。獨自坐
在寓中想到,我生長二十多歲,別的物事見得也多,只有陽物其實不
曾多見。平常的人藏在衣服裡面,自然看不出了。只有那些年少的龍
陽,脫下褲來與我幹事,方才露出前伴。他的年紀輕似我,物事自然
少似我,終日所見都是小似我的,所以就把我的形大了。今被他說所
見之物沒有一根不長大於我,這等我的竟是廢物了,要他何用?只是
一件,我在家中與妻子乾事的時節,她一般也覺得快活。就是往常嫖
女客偷丫鬟,她們一般也浪,一般也丟,若不是這件東西弄得她快
活,難道她自己會浪,自己會丟不成?可見他的話究竟不是真言,還
是推諉的意思。疑了一會,又相一會。忽然了悟道,我曉得了,妻子
的牝戶是件混沌之物,從我開闢出來的。我的多少大,她的就多少
寬;我的多少長,她的就多少深。以短投淺,以細投窄,彼此相當,
所以覺得快活。譬如取耳一般,極細的消息放在極小的耳朵裡面轉動
起來,也覺爽利。若還是寬耳朵遇著細消息,就未必然了。日前賽崑
崙說婦人有心上不浪,口裡假浪之法,焉知那些丫鬟女客不是因得了
我的錢財,故意奉承我,心上其實不要浪,口裡假浪騙我,也不可
知。浪既可假,豈有丟不可假者乎?他說這話雖不可全信,也不可不
信。以後遇著男子,要留心看他的陽物何如,就明白了。

從此以後,與朋友會文的時節,朋友小解,他也隨去小解;朋友大
便,他也跟去大便。把朋友的看一看,又把自己的看一看。果然,沒
有一個不雄似他的。就在路上行走,看是肩上坑上有人絆手,也定要
斜著眼睛,把他的陽物看個仔細。果然個個大也大的他、長也長的
他。自此比驗之後,未央生的慾心也漸漸輕了,色膽也漸漸小了。心
上思量道,賽崑崙的話句句是藥石之言,不可不聽。他還是個男子,
我前日被他一番取笑,尚且滿面羞愧,萬一與婦人幹事弄到半中間被
她輕薄幾句,我還是自己抽出來不干的好、還是放在裡面等她嘔吐出
來的好?從今以後,把偷婦人的事情收拾起,老老實實干我的正經,
只要弄得功名到手,拼些銀子討幾個處女做妾,我自然受她奉承不受
怠慢了。何須陪了精神去做燒香塑佛的事?算計以定,果然從這一日
起,撇卻閒情,專攻舉業。看見婦人來燒香,不但不趕去看,就在外
面撞見,也還要避了進來。至於街坊上行走,看見婦人,低頭而過,
一發不消說了。

準準熬了十餘日,到半月之後,欲心難禁,色膽又大。一日,從街
上走過,看見一個少年婦人把一隻手揭開簾子,露出半個面龐,與對
門的婦人說話。未央生遠遠望見,就把腳勢放鬆,一步勾做三步走,
好慢慢的聽她聲音、看她面貌。只見吐出來的字眼就像簫聲笛韻一
般,又清楚又嬌媚,又輕重得宜。躲著走到門前細看她面貌態度,竟
與賽崑崙所說的話件件相同。也像珍珠寶貝,也像一幅美人圖在簾子
裡隨風吹動。心上想猜,她前日所說的莫不就是此人?

相了一會,走過幾家門面,故意問人道:“這邊有個賣絲的人,叫做
權老實,不知他在哪裡?”那人道:“你走過了。方才那簾子裡面有婦
人說話的就是他家。”未央生知道果然是了,就復轉身來又看個仔細,
方才回到寓中。心上想道,起先,賽崑崙在我面前形容她的標致,我
還不信,只道他未必識貨。那裡曉得是一雙法眼。這一個相得不差,
那一家兩個的自然不消說了。有這樣的佳人,又有那樣的俠士肯替我
出力,只因這一件東西不替我爭氣,把三個好機會都錯過了,怎麼教
人恨得過。懊惱一番就把房門關上,解開褲子,取出陽物來左相一
會,右相一會,不覺大怒起來,恨不得取一把快刀,登時割去,省得
有名無實放在身邊。又埋怨道,這都是天公的不是,你當初既要嬌縱
我,就該嬌縱到底,為甚麼定要留些缺陷?這才貌兩件是中看不中用
的東西,你偏生賦得完備,獨有這件要緊物事捨不得做情。難道叫它
長幾寸大幾分要你費甚麼本錢不成?為何不把別人的有餘損些下來補
我的不足?就說各人的形體賦定了,改移不得,何不把我自己腿上的
皮肉、渾身上下的氣力勻些放在上面,也就夠了。為甚麼把這上邊的
作料反勻到別處去使?人要用的有沒得用,不要用的反餘剩在那邊,
豈不是天公的過處?如今看了這樣標致女子不敢動手,就像飢渴之人
見了美味,口上又生了疔瘡,吃不下去的一般,教人苦不苦?思量到
此,不覺痛哭起來。

哭了一會,把陽物收拾過了,度到廟門前去閒步遣悶。只見照壁上
一張簇新的報帖,未央生向前一看,只見上寫道:天際真人來受房術
能使微陽變成巨物這四句是前面的大字,後面還有一行細字。是偶經
此地,暫寓某寺某房,願受者速來賜顧,遲則不及見矣。未央生看了
不覺大喜道,有這麼樣的奇事,我的陽物渺小,正沒擺佈,怎麼就有
如此的異人到這邊來賣術,豈非天意?遂如飛趕進廟去,封了一封贄
見禮,放在拜匣中,教家童捧了,自己尋到寓處去。只見那為術士相
貌奇偉,是個童顏鶴髮的老人。見他走到,拱一拱手,就問道:“尊兄
要傳房術麼?”未央生道:“然也。”術士道:“尊兄所問還是為人之學
還是為己之學?”未央生道:“請問老先生,為人怎麼樣,為己怎麼
樣?”術士道:“若單要奉承婦人,使她快活,自己不圖歡樂,這樣的
房術最容易傳。不過吃些塞精之藥,使腎水來的遲緩;再用春方搽在
上面,把陽物弄麻木了,就如頑鐵一般,一毫痛癢不知。這就是為人
之學。若還要自家的身子與婦人一齊快活,陰物陽物皆知痛癢--抽
一下,兩邊都要活;抵一下,兩邊都要死。這才叫做交相取樂,只是
快活之極,婦人惟恐丟得遲,男子惟恐丟得早。要使男子越快活而越
不丟;婦人越丟而越快活,這種房術最難,必須有修養的工夫到,再
以藥力助之,方才有這種樂處。尊兄要傳,跟在下云遊幾年,慢慢參
悟出來,方有實際。不是一朝一夕可以得去的。”

未央生道:“這等,學生不能待,還是為人之學罷了。方才見尊禀上
有'能使微陽變成巨物'這八個字,所以特來請教。不知是怎樣方法才能
改變?”術士道:“做法不同,大抵要因才而施。第一,要看他本來的
尺寸生得何如;第二,要於本來尺寸要擴充多少;第三,要問他熬得
熬不得,拼得拼不得。定了規矩,方好下手。”未央生道:“這三件是
怎麼樣,都求老先生明白指教,好得學生擇事而行。”術士道:“若是
本來的尺寸不短小,又於本來尺寸之外擴充不多,這種做法甚容易,
連那拼得拼不得、熬得熬不得的話都不必問,只消用些藥敷在上面,
使它不辨寒熱不知痛癢,然後把藥替它薰洗,每薰一次洗一次,就要
搓一次扯一次。薰之欲其長,洗之欲其大;搓之使其大,扯之使其
長。如此三日三夜,就可比原來尺寸之外長大三分之一。這種做法是
人所樂從的。若還本來的尺寸短少,又要於本來尺寸之外擴充得多,
這種做法就要傷筋動骨了。所以要問他熬得熬不得,拼得拼不得。他
若是個膽小的人,不肯做利害之事也就罷了,若還是愛風流不顧性命
的,就放膽替他改造。改造之法,先用一隻雄狗、一隻雌狗關在空房
裡,它們自然交媾起來。等它們交媾不曾完事之時,就把兩狗分開。
那狗腎是極熱之物,一入陰中長大幾倍,就是精洩後還有半日扯不出
來,何況不曾完事?而這時節先用快刀割斷,然後割開雌狗之陰,取
雌狗之腎,切為四條。連忙把本人的陽物用麻藥麻了,使它不知疼
痛,然後將上下兩旁割開四條深縫,每一條縫內塞入帶熱狗腎一條,
外面把收口靈丹即時敷上。只怕不善用刀,割傷腎管,將來就有不舉
之病,若腎管不傷,再不妨事養到一月之後,裡面就像水乳交融,不
復有人陽狗腎之別。再養幾時,與婦人幹事那種熱性,就與狗腎一
般。在外面看來,已比未做的時節長大幾倍;收入陰中,又比在外的
時節長大幾倍。只當把一根陽物變做幾十根了,你道那陰物裡面快活
不快活?”

未央生聽到此處,竟像已死之人要重新轉活來一般,不覺雙膝跪下
道:“若得如此,恩同再造。”術士連忙扶起道:“尊兄要仿學生服事就
是了,為何行此大禮?”未央生道:“學生賦性好淫,以女色為命。無
奈如先天所限,使我胸中的志願再不能酬。如今得見異人,怎敢不行
北面之禮,就好造次奉求。”說完就喚家童取禮過來,自己親手遞過去
道:“些須不腆,暫為拜見之儀。待改正之後,再當奉獻。”術士
道:“這樁事說便是這等說,十有九分還是做不成的。這個盛儀不敢輕
領。”未央生道:“沒有甚麼做不成。學生賤性是極愛風流,不顧性命
的。若還改造的好,能使微陽便成巨物,將來感恩不淺。就或者用刀
差錯,有傷性命,也是數該如此,學生亦不敢怨。老先生不必多疑。”

術士道:“這法度在下做得慣拿得穩,用刀自無差錯。只是改造之後
有三件不便處,所以不敢輕易任事。須要逐件說過,若還情願如此,
才敢領命。倘三件之中有一件不情願,就不敢相強。”未央生道:“是
哪三件不便處?”術士道:“第一件不便,做過之後有三個月不可行
房。一行了房,裡面就要傷損,使人陽、狗腎兩下分開,不但假的生
不牢,連自己真的也要爛。我起先說熬得熬不得的話,就是為此。第
二件不便,做過之後,除非二三十歲的婦人方能承受,未滿二十者就
是已經破瓜、大而生育的,初乾之時也要受許多磨難。若未曾出嫁的
處女乾一個死一個,決無幸全之理。要做這事,除非戒了不娶頭婚,
不禦少婦,方才使得。不然豈但本人的陰德難全,連代做之人罪過也
不小也。第三件不便,做過之後,後天的人力雖然有餘,那先天的原
氣割的時節未免洩漏了些,定然不足生男育女。即使生男育女,生出
來也都是夭亡者多,長命者少。我起先所說拼得拼不得的話就是為
此。我看尊兄是個青年有志的人,一來欲心太燥,熬不得三月不行
房;二來色心太貪,保不得將來不幸處女;三來年事甚輕,恐怕令郎
還不曾有,就有也不多。我想這三件事皆有礙於尊兄,料尊兄未必件
件情願而敢於輕試也。”

未央生道:“這三件事皆礙學生不著。老先生放心,只管替我改造就
是。”術士道:“怎見得礙不著?”未央生道:“我如今在客邊比在家裡
不同,就是不做此事尚且連夜孤眠,難道做了此事反有甚麼走動不
成?那第一件事是與我無礙的了。有甚麼做不得?”至於結髮妻子不可
娶頭婚,其餘婢妾都可以不論。學生的荊妻已經娶過,可以不消慮
得。況且女色之中極不受用的是處女,一毫人事不知,一些風情不
諳,有甚麼樂處?要幹實事,必待二十以外、三十以內的婦人,才曉
得些起承轉合。與做文字的一般,一段有一段的做法,一般有一般的
對法,豈是開筆的蒙童做得來?那第二件事不但於我無礙,又且與我
相投了。有甚麼做不得?若子息一事別人看得極重,學生看得極輕。
天下的子嗣肖者少,不肖者多;孝順者少,忤逆者多。若僥倖生個好
的出來這不消論,若生個不肖不孝的出來,把家業廢去,又把父親氣
死,要此子何用?況且天下的人十個之中,定有一兩個無子,這都是
他命該絕嗣,難道也是因改造陽物,洩了原氣所以絕嗣不成?我今天
起了這個念頭,就是個無子之兆了,又自己情願無子,一定要割。萬
一命中有子,到那臨割的時節原氣不十分漏洩,依舊會生育男女,生
出來的男女或不到夭亡也未可知。這總是意外的事,我不想,只打點
做個無子的人就是了。老先生所說之事,學生熬也熬得,拼也拼得,
有甚麼不便?如今不消疑我,竟替學生改造就是了。 ”

術士道:“既然尊意甚堅,一定要做,在下不好作難。須要選個日
子,或約在尊館,或屈到小寓,必須做得隱靜,不可使一人知道。若
有人知道走來竊看,就不便行事了。”未央生道:“敝寓往來人雜,難
行此事。不如還到尊寓來罷。”兩個相約定了,術士才把贄儀收下,取
出一本通書,選了日子,是個火日,陽物屬火,取火旺則盛的意思。
改造日子定了,未央生千歡萬喜,分別而去。他生平造孽之根皆始於
此,可見天下學房術是學不得的,學了房術就要壞了心術,從未有學
房術單為奉承妻子,而不淫人妻子者也。

評曰:他人執筆定於未央生知道陽物短小,急急尋人改正。改正之
後好敘淫欲之事,使看書之人精神踴躍,無枝多幹少之嫌。豈肯插入
不看婦人一段,使風流才子忽變為道學先生以冷觀者之目?作者獨於
此處著意,殆有深意存焉。使未央生果於此時改弦易轍,則後來名利
無傷,無妻妾償淫之事矣。可見極惡之人,一念回頭即是彼岸,不可
於回頭之後再轉一念耳。讀此書者當在此處著眼,則於棗肉之中嚼出
橄欖之味,作者深心不待終篇而始見也。

第八回:三月苦藏修良朋刮目一翻喬弄美婦傾心

未央生別了術士,回到寓中,獨自一個睡了。就把改造陽物以後與
婦人幹事的光景預先揣摩起來,不覺淫興大發,一時難禁。只得叫隨
身一個家童上床去睡,把他權當了婦人,恣其淫樂。他有兩個家童,
一個叫做書笥,一個叫做劍鞘。書笥年十六歲,因他識幾個字,未央
生把一廳書籍都交給他掌管,就像個藏書的篋子一般,所以取名叫做
書笥。劍鞘年十八歲,未央生有一口古劍交付他收藏,就像個護劍的
套子一般,所以取名叫做劍鞘。兩個人物都一樣妖姣,姿色都與標致
婦人一般。劍鞘不會作驕態,未央生雖不時弄他還不覺十分得意。書
笥性極狡猾,與未央生行樂之時態聳駕後庭如婦人一般迎合,口裡也
會做些浪聲,未央生最鍾愛他。所以這一晚不用劍鞘,單叫他上床好
發洩狂興。

書笥等他完事之後就問道:“相公這一向單愛婦人,厭棄男子,把我
們拋撇久了。為何今夜高興,溫起舊賬來?”未央生道:“我今晚不是
同你幹事,是與你作別。 ”書笥道:“這麼說,莫非要賣我麼?”未央生
道:“我怎捨得賣你,這'作別'二字不是我同你作別,是我的陽物與你
的後庭作別。”就把要改造陽物的緣故細細說了一遍。書笥道:“這
等,你改造之後一根陽物有幾十根大的,好去偷婦人,量我後庭想是
不能承受了。”未央生道:“是。”書笥道:“你若去偷婦人,少不得要
一個使喚的隨身護駕。就把我帶在身邊,若有多餘的婦人你睡不了
的,賞我一個,等我嚐嚐女色的滋味,也不枉跟個風月主人一場。”未
央生道:“這個容易。' 飽將手下無餓兵',正經的同我睡了,那手下的
丫鬟任憑你睡。莫說一個,就要幾十個也有。”書笥聽了歡喜道:“你
的陽物既與我的後庭作別,我如今也要與你作別了。”就倒爬上身去,
澆了一回本色蠟燭,方才下來。

未央生睡到第二日,就買了一隻極健的雄狗,又買一隻雌的相配,
分作兩處養在寓中。等到約定日期,叫書笥牽了,自己一同過去,又
令劍鞘備一桌酒席,隨後送來。那術士的寓處是個極秘密的所在,沒
有閒雜人往來,極好做事。當日見未央生走到,就叫他取出陽物,預
先上了麻藥,好待臨期用刀。那麻藥初搽上去就像冷水激了一下,一
激之後竟像沒了此物一般。掐也不知疼,搔也不覺癢。未央生放下了
心,知道割的時節沒有苦吃的了。

不多時,酒已送到,與術士一邊吃酒,一邊等雄狗與雌狗幹事。那
兩個畜生牽到僻靜處來,放在一處,它們只道是主人盛意,肯行方
便,就聯絡起來。那裡曉得是主人要藉它本錢?!那兩狗牽來的時節
頸項裡各系一條索子,未肯解去。術士見它們幹到興高之時,就令兩
個家童把兩根牽索用力扯開。雄狗捨不得開交,口裡亂吠,兩隻後腿
緊緊夾住陰物,惟恐它開去;雌狗也捨不得開交,口裡亂吠,兩隻後
腿緊緊夾住陽物,惟恐它出去。術士手持快刀,把狗腎割斷。隨割開
雌狗之陰,取出雄狗之腎,切分四條。就連忙把未央生陽物割開四條
縫,每一條縫內託一條狗腎,帶熱塞進去。四條塞完,外面敷上靈
丹,用汗巾包紮好了,兩個依舊飲酒。

未央生這一晚就在術士寓中藉宿,夜間抵足之時,又傳授了許多戰
法。到第二日才回去將養。這三個月之中也虧他把持得定,不但不想
欲事,連新改的陽物眼也不去看一看。直等過了三個月方才解去汗
巾,把它刮洗出來。仔細一看,不覺大喜道:“魁梧奇偉,果然改觀,
有此異物,可以橫行天下矣。”

又過了數日,忽見賽崑崙走來問道:“賢弟一向不出門,在寓中靜
坐,想舉業的功夫必然長進了。”未央生道:“舉業的功夫不過如此,
倒是房術的功夫有長進了。 ”賽崑崙笑道:“資質不高,長進也有
限。”未央生道:“長兄差了,士三日不見便當刮目相待,何況小弟別
了三月?難道就沒進益麼?何不思三尺之童後來變成大漢,脫兔之師
起先有若處女?只有死人的陽物只會消不會長,哪有活人的東西是人
所能料定的? ”賽崑崙道:“這話我不信,十三四歲的孩子那雞巴不曾
出汁就會一日大似一日,豈有二十以外之人陽物還會發作麼?就發也
發不多,不過論絲論毫,決無論分論寸之理。”未央生道:“莫說論絲
論毫,論分論寸也不足形其所發之長大。”賽崑崙道:“豈有此理。世
上只有暴發的財主,不曾見有暴發的陽物。既然如此求取出來與愚兄
看一看。”未央生道:“前次取出來受兄許多怠慢,如今怎敢再獻
出?”賽崑崙道:“賢弟不要取笑,快取出來。若果然長進,待我奉承
幾句請罪就是了。” 未央生道:“口中奉承也沒幹,除非尋件實事與它
做做,一來試驗它,二來鼓舞它,才見長兄作養人材的盛意。”賽崑崙
道:“若真是長進了我就把前日說的事作養牠。”

未央生道:“既是如此,依舊要出醜了。”就把衣服抄起系在帶間,
次將褲子卸下。然後把兩手捧住陽物,就像波斯獻寶一般,對賽崑崙
道:“長進不長進,看就知了。”賽崑崙遠遠望見,疑是用一條驢腎掛
在腰間騙我。及至近身仔細一看,方才知是真貨,不覺吐舌大驚,問
道:“賢弟用甚麼方法就把一個極疲矮的物事弄得極雄壯起來?”未央
生道:“不知甚麼原故被長兄一激之後,它就平空振作,竟像要發狠爭
氣的一般。連我自己也不能禁止。”賽崑崙道:“你不要騙我。我看皮
膚上現有刀痕,四面四條又是一種顏色,畢竟是用甚麼巧術造作出
來。好好對我直說。”未央生被他盤駁,只得把改造的事細細說了。賽
崑崙道:“賢弟好色之心堅韌至此,真不可阻撓了。我只得完備這件事
罷,今日就同你撞到他家去看機會。”

未央生大喜。換了衣冠同賽崑崙出去。走到相近的所在,賽崑崙把
他安頓在一處,自己先去打探消息。不多時走來回報導:“恭喜、恭
喜,今夜就能成事了。 ”未央生道:“面也不曾見,怎麼就保得今夜成
事?”賽崑崙道:“我方才去問鄰舍,鄰舍說她丈夫往遠處賣絲去了,
有十幾日不得回來。你如今同我走進去用心勾搭她,只要有些情意,
我晚間自有辦法送你進去,包管有十幾夜同她快活就是了。 ”

未央生大喜,兩人連忙走去。到了門前,賽崑崙把簾子倡起,同未
央生一齊鑽進去道:“權大爺在家麼?”婦人道:“不在家。”賽崑崙
道:“在下要買幾斤絲,如今不在家怎麼處?”婦人道:“別處去買罷
了。”未央生就接口道:“絲怕沒處買?只因一向是府上的主顧,不好
去總承別人。”婦人道:“既是捨下的主顧,為甚麼我不認得?”賽崑崙
又接口道:“大娘,我夏天來買絲,也遇著太爺不在,是大娘親自交
易,從架子內取下來與我去的。難道就忘記了? ”婦人道:“是記得有
這一次。”未央生道:“既然大娘記得,可見不是空口來打價了,如今
要有絲,取出來交易就是。為甚麼把自家的生意推到別人家去?”婦人
道:“絲便有幾斤,不知你中意否。”未央生道:“府上的絲豈有不中
意,還是忒好了些,怕我這酸子買不起?”婦人道:“好說,這等相公
請坐了,待我取出來。 ”

賽崑崙就叫未央生坐在上面,自己坐在下面。上面近著婦人,待他
好調情的意思。那婦人取出一捆絲來,遞與未央生看。未央生還不曾
接絲到手,就回復道:“這絲顏色太黃,恐怕用不得。”及至接到手仔
細一看,又道:“好古怪,方才大娘拿在手裡,覺得是焦黃的,如今接
到我手又會白起來,這是甚麼緣故?”故意想了一會又道:“這是大娘
的手忒白了些,所以映得絲黃;如今我的手黑,所以把黃絲都映白
了。”婦人聽了這話,就把一雙眼湊著未央生的手,相了一會,方說
道:“相公的尊手也不叫做黑手。”說便說這一句,還是正言厲色,沒
有一毫嘻笑之容。賽崑崙道:“他的手比了我們的不叫做黑,若比了大
娘的就不叫做白了。” 婦人道:“絲既然白為何不買?”未央生道:“這
是賤手映白的,可見不是真白。畢竟要與大娘的尊手一樣顏色的方是
好絲。求取出來看看。”賽崑崙道:“世上那有這樣白絲,只要像你臉
上這樣顏色,它就用得過了。”婦人聽了這話,又把一雙眼睛湊著未央
生的臉,相了一會,方才有歡喜之容,對他笑道:“只怕世上沒有這樣
白絲。 ”

看官,你道她為甚麼以前不笑,直到此時才笑?以前不顧眄,直到
此時忽然顧眄起來?原來,這婦人是一雙近視眼,隔了二尺路就看不
見。起先,未央生進去,只道是尋常買賣之人,及至聽見“酸子”二
字,方才曉得是個秀才也。還只說是尋常人物,不把眼去相他。因為
睜眼看人有些費力,所以遇見男子不大十分顧眄。但凡為婦人者,一
點雲雨之心,卻與男子一樣都是要認真做事,不肯放鬆的過了。若是
色心太重的婦人,眼睛又能遠視,看見標致男子,豈能保得不動私
情?生平的節操就不能完了。所以造化賦形也有一種妙處,把這近視
眼賦予她,使她除了丈夫之外,隨你潘安、宋玉都看不分明,就省了
許多孽障。所以,近視婦人完節的多,壞事的少,總是那雙眼睛不會
惹事。

這個婦人若不是把幾句巧話引他眼睛上身,隨你立在面前調戲到
晚,她只當在雲霧之中,那裡曉得。只因手上一看,臉上一看,看花
了心,就有些開交不得。對著未央生道:“相公當真買不買?若果然要
買,我房裡有一把好的,取出來看就是。”未央生道:“特地尋來,豈
有不買之理。快取來看。”婦人進去一會,果然取出一捆絲來,又叫一
個□□丫鬟捧了兩盅茶,遞與賽崑崙、未央生吃。未央生不敢吃完,留
了半盅做個轉奉主人之意。婦人看見,又對未央生笑了一笑,方才遞
出絲來。未央生接絲,就趁手把婦人捏了一把。婦人只當不知,也把
指甲在未央生手上兜了一下。塞崑崙道:“這一捆果然好,買了去
罷。”就把銀包遞與未央生。未央生照他說的價錢稱了,遞與婦人。婦
人道:“這銀子成錠,恐怕是中看不中用的。”未央生道:“大娘若不放
心,我把絲與銀子都放在這邊,今晚就夾開一錠,試他一試何如?不
是誇嘴說,我們的銀子都是表裡如一的。”婦人道:“也不消如此,若
果不差,下次還可交易。不然,只好做一遭主顧罷了。”賽崑崙拿著
絲,催未央生回去。未央生臨行,又把婦人唆了幾眼,婦人雖不看
見,也能領略大意,竟把眼睛收做細縫,似笑非笑的模樣送他。

未央生走到寓中問塞崑崙道:“這事有八九分成了,只是今晚怎樣進
去?”賽崑崙道:“我細細打聽過了,她家沒有第二個人,只有方才那
個丫鬟,才十一二歲,夜間跌倒頭就睡著了。她家的房屋是看得見
的,又不是樓房,又不是土穴,只消我背了你爬到她屋上,掀去幾片
瓦,擺去一根椽,做個從天而下罷了。”未央生道:“若還被她鄰舍聽
見,大家捉賊起來怎麼處?”賽崑崙道:“有我在身邊不消多慮。只是
一件,那婦人方才的話說是恐怕你中看不中用的,若還乾得她不快
活,就是一遭主顧了。劣兄前日的話如今可驗了麼。你須要自己掙
扎,不要被她考倒,只進一場,到第二三場就不得進去。”未央生
道:“決不至此,長兄放心。” 兩個笑了一場,巴不得金烏西下,玉兔
東昇,好做進場舉子。但不知那位試官是怎生一個考法,須得題目出
來方知分曉。

評曰:小說,寓言也。言既曰“寓”則非實事。可知此回割狗腎補人
腎非有是理,蓋言未央生將來所行之事,盡狗彘之事也。猶第三回與
賽崑崙結盟,而且以兄事之,蓋言其人品志向猶出盜賊之下也。皆深
惡而痛絕之詞,分明是他做狗烏龜、賊烏龜耳。世人不得認貶為褒,
以虛作實,謂狗真可割而割之,賊真可交而交之,使作賊之人,反蒙
作俑之謗。斯千古文人有同幸矣。

第九回:擅奇淫偏持大體分餘樂反佔先籌

卻說權老實的妻子,名叫艷芳,是個村學究之女。自小也教她讀書
寫字,性極聰明。父母因她姿貌出眾,不肯輕易許人。十六歲上,有
個考案首的童生央人作伐,父親料他有些出息,就許了他。誰想做親
一年就害弱病而死,艷芳守過週年,方才改嫁給權老實。

此婦雖好淫,頗知大體,每見婦人有淫佚之事,就在背後笑她。嘗
對女伴道:“我們前世不修,做了女子,一世不出閨門,不過靠著行房
之事消遣一生,難道好叫做婦人的不要好色?只是一夫一婦乃天地生
成,父母配就,與他取樂自然該當。若要相處別個男人,就是越禮犯
分之事,丈夫曉得要打罵,旁人知道要談論。且無論打罵不打罵,談
論不談論,只是這樁事體不干就罷,要幹定要干個像意。畢竟是自家
丈夫,要做事體兩個脫衣上床,有頭有腦,不慌不忙的做去,做到後
來方才有些妙境。那慌忙急促之中只圖草草完事,不問中竅不中竅,
著題不著題,有些甚麼趣味。況且飢時不點,點時不飢,就像吃飲食
一般,傷飢失飽反要成病。那走邪路的女子,何不把後來相情人的眼
睛留在當初擇婿。若要慕虛名,揀個文雅的;若要圖外貌,選個標致
的;若不慕虛名,不圖外貌,單要幹房中的實事,只消尋個精神健旺
氣力勇猛的,自然不差。何須丟了自己丈夫去尋別個?”那些女伴聽了
都道:“過來的人,說話自然不同,句句親切有味。”

怎見得她是過來的人?她當初做女兒的時節,也慕虛名,也圖外
貌,也要幹實事。及至嫁了那個童生,才也有幾分,貌也有幾分,只
道是三樣俱修的了,誰想本錢竟短小不過,精力又支持不來。爬上身
去肚子不曾猥得熱,就要下來。艷芳是個勤力的人,那里肯容他懶
惰,少不得作興鼓舞,又要聳擁他上來。本領不濟之人,經不得十分
剝削,所以不上一年就害弱症而死。他經過這一番挫折,就曉得“才
貌”二字是中看不中用的東西,三者不可得兼寧可舍虛而取實。所以後
來擇婿,不要才貌,單選精神健旺、氣力勇猛的以備實事之用。看見
權老實,生的粗粗笨笨,精力如狼似虎,知道是有用之材,所以不問
貧富,就嫁了他。起先還單取精力,不知他的器械何如。只說力雄氣
壯之夫,不必定用長槍大斧方能取勝,就是短兵薄刃亦可摧鋒陷陣。
那裡曉得竟是一根丈八長矛,所以艷芳喜出望外,自從嫁他之後,死
心塌地依靠著他,不生一毫妄念。因他生意微細,日進不多,終日替
他絡絲,每日有一二錢進益,故權老實得以清閒度日。

只因那一日合當有事,掀開簾子與對門婦人說話,未央生從門首經
過,把她細看兩番。她因眼睛近視,只看見有個人影在門前過來過
去,卻不知道面貌何如。誰想倒被對門婦人看了一個像意。那婦人有
三十多歲,丈夫也是販絲賣的,與權老實一同去賣,雖不合本,倒像
伙計一般。這個婦人面貌雖醜,性子甚淫。一來因招牌不好,沒人想
她;二來因丈夫凶狠,略有差錯,不是打就是罵,所以還慎法,不敢
胡行。那一日,把未央生看得清清楚楚,待他去後,就走過街來對艷
芳道:“方才一個絕標致男子走來走去,看你兩次。你曉得麼?”艷芳
道:“你知道我的眼睛可是看得人見的,我坐在這邊,哪一日沒有幾個
男人隔著簾子看我,便捨他看看罷了。曉得他做甚麼。”婦人道:“往
常的男子,你這樣人物直不得捨與他看。方才這一個,就等他看了三
日三夜也是情願的。”艷芳道:“怎麼這等說,難道有十二分人才不
成?”婦人道:“豈止十二分?照我看起來,竟有一百二十分。我終日
立在門前,看了許多人,並不見有這樣標致的。臉上皮肉,隨你甚麼
東西沒有那種白法。眉毛、眼睛、鼻頭、耳朵,那一件不生得可愛?
身上俊俏竟像個絹做的人物一般。就是畫上畫的有這般標致,也沒有
這樣飄逸。真教人想思。”

艷芳道:“好笑大娘說得這樣活現。我不信世上有這樣男子,就有這
樣男子,他是他我是我,想他做甚麼?”婦人道:“你便不想他,我看
他好不想你,出神出智,好像落魂了一般。要去又捨不得去,要立又
怕別人知。沒奈何,只得走過去一會,又重新走轉來。臨去的時候又
去看看。你道可憐不可憐?你不曾看見,自然不想他,我看見他,就
替你患起相思病。”艷芳道:“只怕他那種光景不是為我,是為你。你
自己相思不好說,得故意把我來出名。”婦人道:“我好副嘴臉,他肯
為我?其實是為大娘,大娘不信,他少不得還要來走過,我遠遠望見
他來,就知會大娘。大娘把身子立到外面,一來好看他,二來等他也
好看你。”艷芳道:“且等他走過的時節再做道理。”婦人又說許多話,
方才過去。艷芳到第二三日,倒也留心要看,不想過了許多日,再不
見來,也就丟開了。及至這一日,來買絲,看見這副標致面貌,自然
再想起前話來。等他去後,心上想到,前日所說的莫非就是此人不
成?論他外貌,果然是第一品男人,但不知內才何如。他方才有一句
巧話,說今天就夾開來試他一試,雖然是說銀子,卻是雙開二意。萬
一今晚當真走來,我還是拒絕的好,收留的好?終身的名節,壞與不
壞,就在這一刻定局了,不可不自家斟酌。

正在躊躇,只見對門的婦人走過來道:“大娘,方才買絲的人你認得
麼?”艷芳道:“我不認得。”婦人道:“就是我前日說的。你難道不明
白,世上那有第二個男子像這樣標致的?”艷芳道:“果然標致。只是
忒輕薄些,不像正人君子。”婦人道:“大娘又來道學了。世上那有正
人君子肯來看婦人的?我們只取人物罷了,又不要他稱斤兩,管他輕
薄不輕薄。”艷芳道:“是便是這等說,只是在人面前也該穩重些便
好。方才做出許多調戲來,虧得我家主不在,若還在家,看見怎麼了
得?”婦人道:“怎麼樣調戲你?對我說說。”艷芳道:“總是不老成,
說他做甚麼。”

那婦人是個極淫的,聽見“調戲”二字,不知怎麼樣要摟她親嘴,扯
她做事,就不覺搖頭擺尾,把手在艷芳身上左捏一把,右敲一下,定
要她說。艷芳被她纏不過,就回他道:“方才是兩個人,一齊進來,難
道有甚麼別樣?調戲不過就是說話之間眉來眼去,做些勾搭人的意思
就是了。”婦人道:“這等,你也該露些好意回答他。”艷芳道:“我不
罵他就夠了!還有甚麼好意回答他?”婦人道:“這就是你的寡情了。
不要怪我說,倘這樣標致女人,他那樣標致男子,真是天生一對,地
生一雙,原該配做夫妻才是。既不能勾做夫妻也該相處,了了心願。
我想權大爺那樣人物不是你的對頭,一朵鮮花插在牛糞堆上,也覺可
惜。他若再來,我就走過來替你做媒,若把好事幹得一兩遭也不枉為
人在世。”
她一邊講,艷芳一邊算計道,看這婦人心上愛他極了,我就要做這
樁事,她住在對門,若不把些甜頭到她,她豈不壞我的事?我如今不
知那人的本事何如,不如讓她先弄一次,只當委她考試一般。若還本
事好,我然後上場,不怕這樣醜婦奪了我的寵去;若還本事不濟,我
就一頓發作起來,趕他出去就是了,依舊不曾壞得名節,何等不妙?
主意已定,就對她道:“這樣事我其實不做,他若再來,倒不要大娘替
我做媒,待我替大娘作伐,等你兩個做幾遭好事何如?”婦人道:“豈
有此理。莫說大娘這句話未必出於本意,就是出於本心,我這樣醜貌
他那里肯要?大娘若有好意,除非你兩個弄下了手,一遭兩遭之後我
故意撞來,大娘只說不好意思,扯我也乾一遭。這還使得。”艷芳
道:“我這話不是假話,有個做法在這邊。我方才被他歪纏不過,要拒
絕他又放不下臉來,他方才臨去的時節說一句巧話,今晚就要摸來也
不可知。如今你家男子與我家男子一同買賣去了,總則這裡沒人,你
今晚竟鎖了門,到我這邊來睡。預先吹滅了燈,待我躲在暗處,他若
果然來,你竟假充了我同他睡覺。他在暗地裡那裡曉得是你,只當替
我做了一個人情,又保全了我的名節,不致有虧。何等不妙?”婦人
道:“這等說是你許他來的了?我如今心上被你說得癢不過,要辭也辭
不得了。只是一件,你為甚麼許他來又不肯同他幹事?從來的節婦那
裡有這樣做法的?”艷芳道:“不是我假仁假意,定要做這掩耳盜鈴之
事。不瞞大娘說,房事的滋味,我也嘗得透了。隨你有本事的,也趕
我自家的男人不上。吃過大宴席的些須東道看不上眼,葷不葷素不
素,不如不吃的妙。我所以不肯累這個虛名。”婦人道:“你的主意我
知道了,權大爺的本錢是一方有名的,你被大喧頭喧過了,恐怕那喧
週鞋的小喧,撩不著大人的鞋幫,所以要我做個探子,替你探探消息
的。我想這事在我也沒有甚麼折本。只是一件,也要等我干個像意,
不要在要緊頭上,你又自己衝上陣來,使我進退不得。自古道'齋僧不
飽不如活埋',這句話你須要記得。”艷芳道:“料想沒有這等徼幸的
事,你且放心。”兩個商量定了,只等臨期行事。這也是那奇醜的婦人
一時的造化,奉了這個美差。一個簇簇新新改造出來的喧頭,是她這
雙皮鞋喧起。要知寬窄何如,少刻喧時便見。
第十回:聽先聲而知勁敵留餘地以養真才

那個婦人奉了這個美差,滿心歡喜。預先尋幾塊絹袱帶在身邊,好
待乾事之時揩抹淫水,省得濕了別人家的被褥。捱到點燈時候,忙把
門鎖,走過街來。艷芳故意哄他道:“今晚竟是虛貌了,他方才寄個信
來,說被人批住吃酒,脫不得身。還要別約日子。大娘且請回罷。”婦
人聽了,急得眼中火出,鼻內煙生。又怪艷芳不寄信轉去,強她今晚
來,又疑艷芳起先失口許了,如今捨不得讓人,要趕人回去,自己受
用。埋怨了一會,艷芳笑道:“我是哄你。如今想又要來了,只打點與
他幹事就是。”先燒一盆熱水,同婦人淨了下身,然後拿一張春塌,鋪
在床橫頭,自家睡了,好聽他們幹事。吩咐婦人把大門關好,悄悄立
在門後,他若來必輕輕敲門,你聽見敲一下就開門,放他進來。不可
使他敲多次,恐怕隔壁人家聽見。放他進來之後依舊把門閂好,一同
到床上去睡。只是與他說話聲氣要放輕些,恐怕他認得出。婦人唯唯
聽命。艷芳就去睡著了。婦人到大門邊去伺候。

等了一更多天,不見動靜,只得走進房去,正要問艷芳,不想暗地
之中有人摟住她親嘴。婦人只說是艷芳假裝男子和她取笑,就伸手去
摸他褲襠。才伸得下去,就有一根絕大的東西把手撞了一下,方才知
道是本人。就裝出嬌聲來問道:“心肝,你從哪裡進來的?”未央生
道:“是從樑上下來的。”婦人道:“好個本事。如今上床去睡罷。”兩
人遂各自解衣服。未央生不曾解完,婦人已脫得赤條條仰睡在床上
了。未央生爬上肚去,要摸著她兩隻腳好架上肩頭,不想再尋不見。
那裡曉得自上床時節已高高翹在半天,獻出陰戶,只等陽物進來。

未央生想道,不料此婦竟是這等一個淫物,既然如此,那些溫柔的
家數都用不著了,只得賞她一個下馬威。就把下身抬起,離陰戶一尺
多高,挺起陽物朝下一攻。那婦人就像殺豬一般喊起來道:“阿呀!使
不得。求你放輕些。”未央生把兩隻手替她扒開陰戶,慢慢輕輕捱擦捱
擦許久,只進得一寸龜頭,其餘都在外面不能進入。未央生又挺起陽
物朝里一攻。婦人又喊起來道:“使不得!求你用些饞唾。”未央生
道:“只有弄小官用著那件東西,豈有同婦人幹事要用饞唾之理?這例
子破不得,還是乾弄的是。”挺起陽物又向下直攻。婦人道:“使不
得,你若不肯破例,請抽出來,待我自己用些罷。”未央生聽了,就把
陽物拔出,聽她自用。婦人伸開巴掌,吐上許多唾沫,把陰物扒開,
灌了一半進去,餘剩的都搽在陽物上。對未央生道:“如今沒事了,慢
慢弄進去。”

未央生要顯本事,不肯從容,把兩隻手捧住她兩股,響的一聲,將
改造長大的陽物一概事攻進去。婦人又喊起來道:“怎麼你們讀書人倒
是這樣粗鹵,不管人死活,一下就弄到底?如今裡頭著不下,快拿些
出來。”未央生道:“裡頭著不下,難道如今在外面不成?只該叫它活
動些,不要坐冷板凳就是了。”遂運動起來。起初幾下,婦人還當不
起,每送一次,定叫一聲“阿呀”,送到數百之數,就不見則聲了。及
至送到百外,那婦人就有無限的騷狀做出來,無限的淫聲喚出來,使
人禁持不住,只得一陣緊似一陣,要催他丟過了自己好丟的意思。誰
想那婦人有些奸詐,明明丟了兩次,問她,只說“不曾”。為甚麼不說
實話?只因自己是代職的,恐怕艷芳聽見,說她心事已完,要來交
代。未央生認作真話,再不敢丟。抽到後來,忍耐不住,也丟了一
次。丟過之後又不好住手,只是沒有勇往直前之氣。婦人見陽物逡巡
不進,就問道:“你丟了麼?”未央生怕笑他本事不濟,只得也說“不
曾”。起先未問之先,一下軟一下,自從問了這句,竟像學生要睡,被
先生打了,那讀書的精神比未睡時節更加一倍,遂一連抽上幾百下也
不停一停。那婦人叫起來:“心肝,我丟了,我要死了!你今不要動,
摟住我睡罷。”未央生方才住手,抱住酣睡。原來,婦人面貌雖醜,還
虧一雙腳小;肌膚雖黑,還不十分粗糙,所以黑夜認不出是替身。

卻說艷芳躲在床橫頭,側耳細聽。起先見婦人叫疼叫苦,弄不進
去,就知他的傢伙長大,可以用的。又見他的干法在行,抽送有度,
不像沒有來歷的。又見他幹到中間,懈了一陣,雖有些鄙薄之意,後
來見他重整軍容,比入手之初更加奮勇,心上大喜道:“這等看來,分
明是閫內之驍才,色中之飛將了,我今就失身與他亦可無悔。欲要趁
他歇息鑽進被去,說個明白,又怕他在陰暗之中不看見婦人的嘴臉,
只說她好似我,還要想去弄她,況男子久戰之後,若不把姿色去歆動
他,未必能勾再舉。就悄悄走到櫥下,取起火來,先汲了幾瓢水,在
鍋裡下麵點一個草把燒著,然後拿燭光走進房去。把帳一掀,綿被一
揭道:“是哪一個奸賊?深夜闖入人家姦淫婦人,是何道理?快起來說
個明白! ?

未央生在睡夢中忽然驚醒,只說是她的丈夫躲在家中,故意等妻子
同我睡了,走來捉姦,要我的銀子,嚇得牙齒亂鬥。及至抬頭一看,
就是夜間所干的婦人。心上想道,難道他家又有一個不成?低下頭把
那同睡的婦人一看,才知道是個極醜陋之婦。一臉漆黑的癩麻,一頭
焦黃的短髮,顏色就如火腿不曾剝洗過的一般。就大驚道:“這是哪一
個?”婦人道:“你不要驚慌,我是替她做探子的,住在對門。那一
日,你在門前走過,與你說的就是我。她說你容貌雖好,只怕中看不
中用,恐累她偷漢的名,所以央我來試你一試。如今料想見中式了,
你同她睡覺罷。我論理也該睡在這邊,再討些賞賜了去。只是旁邊有
打混的人,你兩個就乾不爽利,不若我回家去睡罷。”說完就起來,只
穿一領綿襖,一條夾褲,其餘衣裙物件都掛在手臂上,帶了回去。臨
去時又對未央生道:“我的容貌雖醜,也是你的功臣。這事是我說起
的,今晚與你睡這一次,一來是大娘的好意,二來也是前世的姻緣。
後來若有閒空的工夫,也還同我睡睡,不要十分寡情。”說完又對艷芳
拜幾拜,謝了東道主人,方才出去。

未央生如醉初醒,如夢初覺,若不是賽崑崙激我改造,今日進來只
好做個秦邦赴考的蘇秦,不中文章,白白趕了出去。艷芳送婦人去
後,把門閉好了走進房來,對未央生道:“我曉得你今夜放我不過,特
尋一個替身等你,你如今與他幹事一次,也消得我的賬了,還不出
去,在這里幹甚麼?”未央生道:“不但消不得賬,還要加你的罪,如
今已是半夜了,快些上床來睡睡。”艷芳道:“你且起來披了衣服,做
一件緊要事,才好同睡。”未央生道:“除了這一樁,還有甚麼緊要
事?”艷芳道:“你不要管,只爬起來。 ”說完走到櫥下,把起先溫的熱
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.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebooknice.com

You might also like