How to work with the documentation
Agreed notations
Introduction
Lesson 1. Navigation menu
Lesson 2. Navigation menu and page structure
Lesson 3. First step—news section
Lesson 4. Second step—working with databases
Lesson 5. User-defined classes in Parser
Lesson 6. Working with XML
Syntax
Variables
Hash (associative array)
Object of a class
Static fields and methods
User-defined classes and operators
Methods and user-defined operators
Passing parameters
Properties
Literals
String literals
Numeric literals
Logical literals
Literals in expressions
Operators
Operators in expressions and their precedence
def. Checking if object is defined
in. Checking if document is in directory
-f and -d. Checking if a file or directory exists
is. Checking type
Adding comments to parts of expressions
eval. Evaluating mathematical expressions
Branch operators
if. Choose one of the two branches
switch. Choosing one of multiple branches
Loop-operators
for. Loop with specified number of repetitions
while. Loop with condition
break. Force finishing loop
continue. Finishing current loops` step
connect. Connecting to a database
use. Linking modules
cache. Caching results of code’s work
process. Compiling and processing string
rem. Adding comments
External and internal data
untaint, taint. Transforming data
Error handling
try. Intercepting and handling errors
throw. Reporting an error
@unhandled_exception. Outputting unhandled errors
System errors
User-defined operators
Charsets
Class MAIN. Processing request
Bool class
Console class
Static field
Reading a line
Writing a line
Cookie class
Static fields
Accessing
Storing
fields. All cookies
Date class
Constructors
create. Relative date
create. Arbitrary date
create. Date and time in standard DBMS format
create. Copying existing date
now. Current date
unix-timestamp. Date and time in UNIX format
Fields
Methods
roll. Shifting date
sql-string. Getting date in DBMS-style format
unix-timestamp. Converting date and time to UNIX format
last-day. Getting last day of month
gmt-string. Converting date to string in RFC 822 format
Static methods
calendar. Creating calendar for specified week
calendar. Creating calendar for specified month
last-day. Getting last day of month
Double, Int classes
Methods
int, double, bool. Transforming objects into numbers or bool
inc, dec, mul, div, mod. Simple operations on numbers
format. Outputting number in specified format
Static methods
sql. Retrieving number from database
Env class
Static fields
Retrieving values of HTTP-header fields
Retrieving Parser version
File class
Constructors
load. Loading file from disk or HTTP-server
sql. Loading file from SQL-server
stat. Retrieving information about a file
cgi and exec. Executing a program
base64. Decoding from Base64
create. Text file creation
Fields
Methods
save. Saving file to disk
sql-string. Saving file to SQL-server
base64. Encoding to Base64
md5. MD5 hash of file
crc32. File checksum calculation
Static methods
delete. Deleting file from disk
find. Finding file on disk
list. Getting directory listing
copy. Copying file
move. Moving or renaming a file
lock. Exclusive use of code
dirname. Path to file
basename. Name of file without path
justname. Name of file without extension
justext. File’s extension
fullpath. Full name of file from server’s root directory
base64. Encoding to Base64
md5. MD5 hash of file
crc32. File checksum calculation
Form class
Static fields
Getting form field value
imap. Getting mouse click coordinates
qtail. Getting query string remainder
fields. All form fields
tables. Getting multiple field values
files. Getting multiple files
Hash class
Constructors
create. Creating an empty hash or copying existing hash
sql. Getting SQL-query result as a hash
Fields
Using hash instead of table
Methods
_keys. List of hash keys
_count. Number of hash keys
foreach. Going through hash keys
delete. Deleting key/value pair
contains. Check for existance key in hash
Working with sets
sub. Subtracting hashes
add. Adding hashes
union. Joining hashes
intersection. Intersecting hashes
intersects. Checking if hashes intersect
Hashfile class
Constructor
open. Opening or creating
Reading
Writing
Methods
hash. Converting to usual hash
foreach. Going through hash keys
delete. Deleting key/value pair
delete. Deleting files from disk
cleanup. Delete expired pairs
release. Save data on disk and unlock files
Image class
Constructors
measure. Creating an object based on existing graphics file
create. Creating an object with specified dimensions
load. Creating an object based on graphics file in GIF format
Fields
Methods
html. Displaying an image
gif. Encoding objects of class image in GIF format
Drawing methods
Line style and width
line. Drawing a line on an image
pixel. Work with image pixels
fill. Filling one-color areas of an image
rectangle. Drawing rectangles
bar. Drawing filled rectangles
polyline. Drawing broken lines through joints coordinates
polygon. Drawing polygons through joints coordinates
polybar. Drawing filled polygons through joints coordinates
replace. Replacing color in the area specified by coordinates table
circle. Drawing an unfilled circle
arc. Drawing an arc
sector. Drawing a sector
font. Loading font file to make an inscription on an image
text. Making an inscription on an image
length. Getting inscription’s length in pixels
copy. Copying image fragments
Inet class
Static methods
aton. Convert string with IP address to number
ntoa. Convert number to a string with IP address
Junction class
Mail class
Static methods
send. Sending a message via e-mail
Math class
Static fields
Static methods
abs, sign. Operations with number sign
round, floor, ceiling. Rounding of number
trunc, frac. Operations with integer/fractional part
degrees, radians. Degrees-radians transformation
sin, asin, cos, acos, tan, atan. Trigonometric functions
exp, log, log10. Logarithmic functions
pow. Raising a number to power
sqrt. Square root of a number
random. Random number
uuid. Universally unique identifier
uuid64. 64-bit unique identifier
md5. MD5 hash of a string
crypt. Hashing passwords
crc32. String checksum calculation
sha1. SHA1 hash of string
Memory class
Static method
compact. Collecting garbage
Reflection class
Static methods
create. Create an object
classes. Classes listing
class. Object's class
class_name. Name of object's class
base. Object's base class
base_name. Name of object's base class
methods.Class's methods listing
method_info. Getting information about method
fields. Object's fields listing
dynamical. Getting method's call type
Regex class
Constructor
create. Creating an object
Fields
Request class
Static fields
uri. Getting the URI of the page
query. Getting the query string
charset. Specifying server’s charset
post-charset. Getting the character set specified in incoming POST request
body. Getting query’s text
document-root. Root of web-space
argv. Command line parameters
Response class
Static fields
HTTP-response headers
headers. HTTP-response headers
body. Specifying a new response body
download. Specifying a new response body
charset. Specifying response charset
Static methods
clear. Cancelling re-definition
Status class
Fields
rusage. Information on resources used
memory. Information on memory—controlled by garbage collector
pid. Process identifier
tid. Thread identifier
String class
Static methods
sql. Retrieving string from a database
base64. Decoding from Base64
js-unescape. Decoding similar to unescape function in JavaScript
Methods
int, double, bool. Converting string into number or bool
format. Outputting a number in specified format
split. Splitting a string
upper, lower. Changing case of the string
length. Getting string's length
mid. Getting substring from a specified position
left, right. Getting substring on the left and on the right
pos. Getting substring's position
replace. Replacing substrings in the string
save. Saving string to a file
match. Matching a pattern
match. Replacing pattern-matching substring
trim. Trimming letters
base64. Encoding to Base64
js-escape. Encoding similar to escape function in JavaScript
Table class
Constructors
create. Creating an object based on a specified table
create. Copying existing table
load. Loading table from a file or HTTP-server
sql. Querying database
Options of file format
Copying and search options
Retrieving data stored in a column
Retrieving data stored in current row as a hash
Methods
save. Saving table to a file
count. Number of rows in table
menu. Iterating through all table rows
append. Appending data to a table
offset. Changing current row offset
offset and line. Getting current row offset
sort. Sorting table data
join. Joining two tables
flip. Transposing a table
locate. Locating a specified value in a table
select. Selecting entries
hash. Transforming a table into hash with specified keys
columns. Getting a table's structure
Void class
Methods
int, double, bool
length. Length of a “string”
pos. Getting position of substring
left, right, mid. Getting substring
Static method
sql. SQL-query returning no result
XDoc class
Constructors
create. Creating a document based on specified XML
create. Creating a new empty document
create. Creating a document based on specified file
load. Loading XML from disk or HTTP-server or other source
parser://method/parameter. Reading XML from arbitrary source
Parameter of creating a new document: Base path
Methods
DOM
string. Converting document into string
save. Saving document to file
file. Converting document into object of class file
transform. XSL transformation
Document-to-text conversion parameters
Fields
DOM
search-namespaces. Name spaces hash to search in
XNode class
Methods
DOM1
select. XPath search for node
selectSingle. XPath search for single node
selectString. XPath search for a string
selectNumber. XPath search for a number
selectBool. XPath search for a Boolean value
Fields
DOM
Constants
DOM. nodeType
Appendix 1. Paths to files and directories, working with HTTP-servers
Variable CLASS_PATH
Appendix 2. Format strings
Appendix 3. Format of connect string used by operator connect
For MySQL
For SQLite
For ODBC
For PostgreSQL
For Oracle
ClientCharset. Connect parameter—charset of communication with SQL server
Appendix 4. Perl Compatible Regular Expressions
Appendix 5. How to name variables, methods, and classes correctly
Appendix 6. How to fight errors and read someone else’s code
Appendix 7. SQL queries with bound variables
Installing and configuring Parser
Configuration file
Configuration method
File defining charset: format description
Installing Parser on Apache web-server, CGI script
Installing Parser on Apache web-server, server module
Installing Parser on web-server IIS, version 5.0 or higher
mod_rewrite analogue
Using Parser as standalone interpreter
Compiling Parser from source code