PHP Examples
- Chapter 1
- Figure 1-1: Printing Today's Date
- Figure 1-2: Re-Formatting for Readability
- Figure 1-3: Assigning Values to Variables
- Figure 1-4: HTML Form for Lunch Information
- Figure 1-6: Conditional Daily Message
- Figure 1-7: Today's Daily Affirmation
- Chapter 2
- Figure 2-2: Experimenting with Type Conversion
- Figure 2-3: Experimenting with Scope
- Figure 2-4: Demonstration of Static Variables
- Figure 2-7: Using a Constant
- Figure 2-9: Comparing Pre-Increment to Post-Increment
- Figure 2-15: The Concatenation Operator
- Figure 2-18: String/Number Conversion
- Figure 2-19: Using Parentheses
- Chapter 3
- Figure 3-2: if-elseif-else Statement
- Figure 3-3: Simple if Statement
- Figure 3-4: Covering all cases with if-elseif-else
- Figure 3-7: Covering all cases with switch
- Figure 3-9: Using while to print day names
- Figure 3-10: Leaving a loop using break
- Figure 3-11: Using do...while to print day names
- Figure 3-13: A Typical for loop
- Figure 3-14: Using for to print day names
- Chapter 4
- Figure 4-2: A Simple Function
- Figure 4-3: A Simple Function Using return
- Figure 4-4: Passing Arguments by Reference
- Figure 4-5: Arguments with Default Values
- Figure 4-6: Using Recursion
- Figure 4-7: Dynamically Calling a Function
- Chapter 5
- Figure 5-1: Referencing array elements
- Figure 5-2: Adding to an Array
- Figure 5-3: Indexing Arrays with Strings
- Figure 5-4: Initializing an Array
- Figure 5-5: Using an array to translate values
- Figure 5-6: Creating and Referencing a Multi-Dimensional Array
- Chapter 6
- Figure 6-2: Using Classes
- Chapter 7
- Figure 7-1: Sending HTML with print
- Figure 7-2: Getting Form Input
- Figure 7-3: File Upload
- Figure 7-4: Viewing Environment Variables
- Figure 7-6: Including a File
- Figure 7-7: Writing and Reading from File
- Chapter 8
- echo
- printf
- chdir
- chgrp
- chmod
- chown
- closedir
- copy
- dir
- fclose
- fgetc
- fgets
- fgetss
- file
- file_exists
- fileatime
- filectime
- filegroup
- fileinode
- filemtime
- fileowner
- fileperms
- filesize
- filetype
- fopen
- fpassthru
- fputs
- fseek
- ftell
- gzfile
- gzgetc
- gzgets
- gzgetss
- gzpassthru
- gzputs
- gzrewind
- gzseek
- gztell
- is_dir
- is_executable
- is_file
- is_link
- is_readable
- is_writeable
- link
- linkinfo
- mkdir
- opendir
- popen
- readfile
- readgzfile
- readlink
- rename
- rewind
- rewinddir
- rmdir
- stat
- symlink
- touch
- umask
- unlink
- dblist
- get_browser
- get_cfg_var
- get_current_user
- getlastmod
- getmyinode
- getmypid
- getmyuid
- phpinfo
- phpversion
- show_source
- openlog
- exec
- getenv
- system
- getallheaders
- header
- setcookie
- checkdnsrr
- getmxrr
- fsockopen
- gethostbynamel
- mail
- Chapter 9
- define
- defined
- doubleval
- empty
- gettype
- get_meta_tags
- intval
- is_array
- is_double
- is_integer
- is_object
- is_string
- is_type
- isset
- settype
- strval
- unset
- array_walk
- arsort
- asort
- count
- current
- each
- end
- explode
- implode
- key
- ksort
- list
- max
- min
- next
- prev
- reset
- rsort
- sort
- uasort
- usort
- uksort
- eval
- sprintf
- strcasecmp
- strcasecmp
- strlen
- strpos
- strrpos
- strcspn
- strspn
- strstr
- strtok
- substr
- addslashes
- base64_decode
- base64_encode
- basename
- chop
- chr
- crypt
- decrypt
- dirname
- escapeshellcmd
- htmlentities
- ltrim
- md5
- newline_to_br
- ord
- parse_str
- parse_url
- quotemeta
- rawurldecode
- rawurlencode
- soundex
- sql_regcase
- stripslashes
- strrev
- strtolower
- strtoupper
- strtr
- trim
- ucfirst
- ucwords
- urldecode
- urlencode
- ereg
- ereg_replace
- split
- Chapter 10
- abs
- acos
- asin
- atan
- atan2
- bindec
- ceil
- cos
- decbin
- dechex
- decoct
- deg2rad
- exp
- floor
- hexdec
- log10
- octdec
- pi
- pow
- rad2deg
- round
- sin
- sqrt
- tan
- getrandmax
- rand
- tempnam
- uniqid
- bcadd
- bccomp
- bcdiv
- bcmod
- bcmul
- bcpow
- bcsqrt
- bcsub
- Chapter 11
- checkdate
- date
- getdate
- gmdate
- gmmktime
- microtime
- mktime
- time
- frenchtojd
- gregoriantojd
- jddayofweek
- jdmonthname
- jdtofrench
- jdtogregorian
- jdtojewish
- jdtojulian
- jewishtojd
- juliantojd
- bcscale
- clearstatcache
- define_syslog_variables
- dl
- error_reporting
- magic_quotes_runtime
- register_shutdown_function
- setlocale
- set_time_limit
- short_tags
- sleep
- usleep
- Chapter 12
- getimagesize
- imagearc
- imagechar
- imagecharup
- imagecolorallocate
- imagecolorat
- imagecolorclosest
- imagecolorexact
- imagecolorresolve
- imagecolorsforindex
- imagecolorstotal
- imagecolortransparent
- imagecopyresized
- imagecreate
- imagecreatefromgif
- imagedashedline
- imagedestroy
- imagefilledpolygon
- imagefilledrectangle
- imagefilltoborder
- imagefontheight
- imagefontwidth
- imageinterlace
- imageline
- imageloadfont
- imagepolygon
- imagerectangle
- imagesetpixel
- imagestring
- imagestringup
- imagesx
- imagettftext
- Chapter 13
- dbase_add_record
- dbase_create
- dbase_delete_record
- dbase_get_record
- dbase_pack
- dbmdelete
- dbmexists
- dbmfetch
- dbmfirstkey
- dbminsert
- dbmopen
- dbmreplace
- filepro
- filepro_fieldcount
- filepro_fieldname
- filepro_fieldtype
- filepro_retrieve
- filepro_rowcount
- filepro_fieldwidth
- imap_8bit
- imap_append
- imap_base64
- imap_body
- imap_check
- imap_createmailbox
- imap_delete
- imap_deletemailbox
- imap_expunge
- imap_fetchbody
- imap_fetchstructure
- imap_header
- imap_headers
- imap_listmailbox
- imap_listsubscribed
- imap_mail_copy
- imap_mail_move
- imap_mailboxmsginfo
- imap_num_msg
- imap_num_recent
- imap_ping
- imap_qprint
- imap_renamemailbox
- imap_reopen
- imap_subscribe
- imap_undelete
- imap_unsubscribe
- ldap_add
- ldap_delete
- ldap_dn2ufn
- ldap_explode_dn
- ldap_get_attributes
- ldap_get_values
- ldap_list
- ldap_modify
- ldap_next_attribute
- ldap_next_entry
- ldap_read
- ldap_search
- msql_connect
- msql_create_db
- msql_data_seek
- msql_db_query
- msql_drop_db
- msql_error
- msql_fetch_array
- msql_fetch_field
- msql_fetch_object
- msql_fetch_row
- msql_field_seek
- msql_fieldflags
- msql_fieldlen
- msql_fieldname
- msql_fieldtable
- msql_fieldtype
- msql_free_result
- msql_list_dbs
- msql_list_fields
- msql_list_tables
- msql_num_fields
- msql_num_rows
- msql_pconnect
- msql_result
- mysql_affected_rows
- mysql_close
- mysql_create_db
- mysql_data_seek
- mysql_db_query
- mysql_drop_db
- mysql_errno
- mysql_fetch_array
- mysql_fetch_field
- mysql_fetch_lengths
- mysql_fetch_object
- mysql_fetch_row
- mysql_field_flags
- mysql_field_len
- mysql_field_name
- mysql_field_seek
- mysql_field_table
- mysql_field_type
- mysql_free_result
- mysql_insert_id
- mysql_list_dbs
- mysql_list_fields
- mysql_list_tables
- mysql_pconnect
- mysql_result
- odbc_autocommit
- odbc_binmode
- odbc_close
- odbc_close_all
- odbc_commit
- odbc_cursor
- odbc_fetch_into
- odbc_field_len
- odbc_field_name
- odbc_field_type
- odbc_free_result
- odbc_num_fields
- odbc_num_rows
- odbc_pconnect
- odbc_prepare
- odbc_result
- odbc_result_all
- odbc_rollback
- ora_bind
- ora_commit
- ora_commitoff
- ora_commiton
- ora_do
- ora_exec
- ora_fetch_into
- ora_plogon
- ora_rollback
- pg_cmdtuples
- pg_dbname
- pg_errormessage
- pg_exec
- pg_fetch_array
- pg_fetch_object
- pg_fetch_row
- pg_fieldname
- pg_fieldnum
- pg_fieldprtlen
- pg_getlastoid
- pg_host
- pg_locreate
- pg_loopen
- pg_loread
- pg_loreadall
- pg_lounlink
- pg_lowrite
- pg_options
- pg_pconnect
- pg_port
- pg_tty
- snmpget
- snmpwalk
- sybase_data_seek
- sybase_fetch_array
- sybase_fetch_object
- sybase_fetch_row
- sybase_field_seek
- sybase_get_last_message
- sybase_min_error_severity
- sybase_min_message_severity
- sybase_pconnect
- sybase_result
- velocis_autocommit
- velocis_commit
- velocis_exec
- velocis_off_autocommit
- velocis_rollback
- Chapter 14
- Figure 14-1: Bubble Sort
- Figure 14-2: Quicksort
- Figure 14-3: Using the sort Function
- Figure 14-4: Using the asort Function
- Figure 14-5: Using the arsort Function
- Figure 14-6: Using the ksort Function
- Figure 14-7: Using the usort function
- Figure 14-8: A Binary Search
- Figure 14-9: Getting Random Numbers
- Figure 14-10: Random Number Function
- Figure 14-11: Generating a Session Identifier
- Chapter 15
- Figure 15-1: Tokenizing a Paragraph
- Figure 15-5: Checking a ZIP Code
- Figure 15-6: Evaluating HTTP_USER_AGENT
- Figure 15-7: Scanning Text for URLs
- Figure 15-8: Replacing linefeeds with HTML line breaks
- Chapter 16
- Figure 16-4: Creating HTML Table from a Query
- Figure 16-6: Checking Session ID
- Figure 16-8: A Simple BBS
- Chapter 17
- Figure 17-1: GIF Button
- Figure 17-2: Creating Button Dynamically
- Figure 17-3: Creating a Bar Graph
- Figure 17-4: Creating a Pie Chart
- Chapter 18
- Figure 18-1: Formatting Function
- Figure 18-2: Dressing up CGI Output
- Figure 18-3: Catalog Request Form
- Figure 18-5: Mixing PHP and HTML
- Figure 18-6: Converting Script to be All PHP
- Figure 18-10: Page-Building Script
- Figure 18-11: DateSelector
- Figure 18-12: Passing an Array via a Form
- Chapter 20
- Figure 20-1: Executing Code in a Loop
- Figure 20-2: Calling a Function in a Loop