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
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
break. Force finishing loop
continue. Finishing current loops` step
for. Loop with specified number of repetitions
while. Loop with condition
connect. Connecting to a database
use. Linking modules
cache. Caching results of code’s work
process. Compiling and processing string
return. Returning from a method
sleep. Delay of execution
rem. Adding comments
External and internal data
untaint, taint, apply-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
Curl class
Static methods
info. Retrieving information about last request
version. Returning cURL library version
load. Loading file from HTTP/HTTPS server
session. Creating cURL session
options. Defining session's options
Class options
Date class
Constructors
create. Relative date
create. Arbitrary date
create. Date and time in standard DBMS format
create. Date and time in ISO 8601 format
create. Copying existing date
now. Current date
today. Current date
unix-timestamp. Date and time in UNIX format
Fields
Methods
gmt-string. Converting date to string in RFC 822 format
iso-string. Converting date to string in ISO 8601 format
last-day. Getting last day of month
roll. Shifting date
sql-string. Getting date in DBMS-style format
unix-timestamp. Converting date and time to UNIX format
Static methods
calendar. Creating calendar for specified week
calendar. Creating calendar for specified month
last-day. Getting last day of month
roll. Setting default timezone
Double, Int classes
Methods
format. Outputting number in specified format
inc, dec, mul, div, mod. Simple operations on numbers
int, double, bool. Transforming objects into numbers or bool
Static methods
sql. Retrieving number from database
Env class
Static fields
fields. Retreve all environment fields
PARSER_VERSION. Retrieving Parser version
Static fields
Retrieving values of HTTP-header fields
File class
Constructors
base64. Decoding from Base64
cgi and exec. Executing a program
create. File creation
load. Loading file from disk or HTTP-server
sql. Loading file from SQL-server
stat. Retrieving information about a file
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
at, _at. Element access by index
contains. Check for key existance in hash
count, _count. Number of hash keys
delete. Deleting key/value pair
foreach. Going through hash elements
keys, _keys. List of hash keys
reverse. Reverse elements order
select. Selecting elements
sort. Sorting hash
Working with sets
add. Adding hashes
intersection. Intersecting hashes
intersects. Checking if hashes intersect
sub. Subtracting hashes
union. Joining hashes
Hashfile class
Constructor
open. Opening or creating
Reading
Writing
Methods
cleanup. Delete expired pairs
delete. Deleting files from disk
delete. Deleting key/value pair
foreach. Going through hash keys
hash. Converting to usual hash
release. Save data on disk and unlock files
Image class
Constructors
create. Creating an object with specified dimensions
load. Creating an object based on graphics file in GIF format
measure. Creating an object based on existing graphics file
Fields
Methods
html. Displaying an image
gif. Encoding objects of class image in GIF format
Drawing methods
Line style and width
arc. Drawing an arc
bar. Drawing filled rectangles
circle. Drawing an unfilled circle
copy. Copying image fragments
fill. Filling one-color areas of an image
font. Loading font file to make an inscription on an image
length. Getting inscription’s length in pixels
line. Drawing a line on an image
pixel. Work with image pixels
polybar. Drawing filled polygons through joints coordinates
polygon. Drawing polygons through joints coordinates
polyline. Drawing broken lines through joints coordinates
rectangle. Drawing rectangles
replace. Replacing color in the area specified by coordinates table
sector. Drawing a sector
text. Making an inscription on an image
Inet class
Static methods
aton. Convert string with IP address to number
ip2name. Determine domain name by IP address.
name2ip. Determine IP address by domain name.
ntoa. Convert number to a string with IP address
Junction class
Json class
Static methods
parse. Parsing JSON string into hash
string. Converting Parser object into JSON-string
Mail class
Static methods
send. Sending a message via e-mail
Math class
Static fields
Static methods
abs, sign. Operations with number sign
convert. Converting number from one base to another
crc32. String checksum calculation
crypt. Hashing passwords
degrees, radians. Degrees-radians transformation
digest. Cryptographic hashing
exp, log, log10. Logarithmic functions
md5. MD5 hash of a string
pow. Raising a number to power
random. Random number
round, floor, ceiling. Rounding of number
sha1. SHA1 hash of string
sin, asin, cos, acos, tan, atan. Trigonometric functions
sqrt. Square root of a number
trunc, frac. Operations with integer/fractional part
uuid. Universally unique identifier
uuid64. 64-bit unique identifier
Memcached class
Constructors
open. Creating object
Reading
Writing
Methods
add. Adding item
clear. Deleting all data
delete. Delete key/value pair
mget. Getting multiple items
release. Closing connection to server
Connection parameters
Memory class
Static methods
auto-compact. Automatic garbage collection
compact. Garbage collection
Reflection class
Static methods
base. Object's base class
base_name. Name of object's base class
class. Object's class
class_by_name. Getting class by name
class_name. Name of object's class
classes. Classes listing
copy. Copying object's fields
create. Create an object
def. Checking existance
delete. Delete object's field
dynamical. Getting method's call type
field. Getting object's field
fields. Object's fields list
fields_reference. Reference on object's fields
filename. Getting file name
is. Cheking type
method. Getting object's method
method_info. Getting information about method
methods.Class's methods listing
mixin. Class extension
stack. Methods call stack trace
tainting. String transformations
uid. Get object's unique identifier
Regex class
Constructor
create. Creating an object
Fields
Request class
Static fields
argv. Command line parameters
body. Getting query’s text
body-charset, post-charset. Getting the character set specified in incoming POST request
body-file, post-body. Getting query's content
charset. Specifying server’s charset
document-root. Root of web-space
headers. Getting the HTTP request headers
method. Getting the HTTP request method
query. Getting the query string
uri. Getting the URI of the page
Response class
Static fields
HTTP-response headers
body. Specifying a new response body
charset. Specifying response charset
download. Specifying a new response body
headers. HTTP-response headers
Static methods
clear. Cancelling re-definition
Status class
Fields
memory. Information on memory—controlled by garbage collector
pid. Process identifier
rusage. Information on resources used
tid. Thread identifier
String class
Static methods
base64. Decoding from Base64
idna. Decoding from IDNA
js-unescape. Decoding similar to unescape function in JavaScript
sql. Retrieving string from a database
unescape. Decoding from JavaScript or URI
Methods
base64. Encoding to Base64
format. Outputting a number in specified format
int, double, bool. Converting string into number or bool
idna. Encoding to IDNA
js-escape. Encoding similar to escape function in JavaScript
left, right. Getting substring on the left and on the right
length. Getting string's length
match. Matching a pattern
match. Replacing pattern-matching substring
mid. Getting substring from a specified position
pos. Getting substring's position
replace. Replacing substrings in the string
save. Saving string to a file
split. Splitting a string
trim. Trimming letters
upper, lower. Changing case of the string
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
Updating data stored in a column
Retrieving data stored in current row as a hash
Methods
append. Appending row to a table
columns. Getting a table's structure
count. Number of rows in table
csv-string. Converting table to string in CSV format
flip. Transposing a table
foreach. Iterating through all table rows
hash. Transforming a table into hash with specified keys
insert. Inserting row into a table
join. Joining two tables
locate. Locating a specified value in a table
menu. Iterating through all table rows
offset and line. Getting current row offset
offset. Changing current row offset
rename. Changing column name
save. Saving table to a file
select. Selecting entries
sort. Sorting table data
Void class
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
file. Converting document into object of class file
save. Saving document to file
string. Converting document into string
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 web-server as CGI
Installing Parser on web-server Apache as module
Installing Parser on web-server IIS, version 5.0 or higher
mod_rewrite analogue
Using Parser as a web server
Using Parser as a standalone interpreter
Source codes
Compile under *nix
Compile under Windows