Programming PHP



Index

Current Working Area
PHP & MySQL
PHP

PHP For Kids

HTML element reference - MDN


Programming PHP - First Edition Online - Creating Dynamic Web Pages - Kevin Tatroe, Peter MacIntyre, and Rasmus Lerdorf - 3rd Edition - About this book 1 - 2


Cover
Boot teaches everything we need creating effective web applications - starting with big picture - diving into language syntax and programming techniques - become a top-notch PHP programmer

Foreword
by Michael P. Bourque

Preface
...

Contents of This Book
Read from start or jump around - ...


CHAPTER 1 - Introduction to PHP

What Does PHP Do?
p1 - Used in 3 ways:
Server-side scripting - PHP was designed to create dynamic web content - generating XML documents, graphics, FLASH animations, PDF files and much more
Command-side scripting - used for system administration tasks, backup and log parsing - even some CRON job type scripts can be done this way (nonvisual PHP tasks)
Client-side GUI applications - using PHP-GTK, you can write full-blown, cross-platform GUI applications in PHP

This book concentrates on dynamic web content
PHP runs on all major operating systems - used with leading web servers
Flexible - not limited outputting just HTML or other text files - any document format can be generated - built-in support for generating PDF files, GIF, JPEG, and PNG images, and Flash movies
Wide-ranging support for databases - with PHP creating web pages with dynamic content from a database is remarkably simple
Library of PHP code to perform common tasks - with the PHP Extension and Application Repository (PEAR) - PEAR is a framework and distribution system for reusable PHP components

A Brief History of PHP
p2 - Version PHP 1.0 since June 1995 - PHP 2.0 April 96 - PHP 3.0 June 97 - project changed from one-person effort with a few contributors to a true open source project with many developers around the world - PHP 4.0 May 22, 2000 - now PHP 5.4 etc.

The Widespread Use of PHP
p6 - 77.8% of websites use PHP server-side

Installing PHP
p7 - Go php.net/manual/install.php
php.ini - PHP’s configuration settings - go de3.php.net/manual/en/configuration.file.php
To change PHP configuration file and restart Apache server - each time you make a change to PHP’s environment, you have to restart the Apache server in order for those changes to take effect - settings are maintained in a file called php.ini - in general the code in this book does not require a customized configuration - change php.ini.default: command+shift G > /etc/php.ini.default - open with Sublime text 2 or other editor

A Walk Through PHP
PHP pages are generally HTML pages with PHP commands embedded - in contrast to many other dynamic web page solutions, which are scripts that generate HTML
<?php echo "Hello, world!"; ?> // echo command produces output of string

Example 1-1
- hello_world.php

Configuration Page
p8 - The PHP function phpinfo() creates an HTML page full of information on how PHP was installed and is currently configured. You can use it to see whether you have particular extensions installed, or whether the php.ini file has been customized

Example 1-2 - localhost/~Feroniba/phpinfo.php - PHP Version 5.4.24 - Apache Version 2.2.26 -

Forms

<?php if(!empty($_POST['name'])) {
echo "Greetings, {$_POST['name']}, and welcome.";
} ?>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> Enter your name: input type="text" name="name" />
<input type="submit" />
</form>

Example 1-3 form.php - localhost

PHP programs access form values primarily through the $_POST and $_GET array variables - more Chapter 7 - (for now be sure that you are processing your pages with the REGISTER_GLOBALS value set to off (the default) in the php.ini file) - REGISTER_GLOBALS feature has been removed as of PHP 5.4

Databases
PHP supports all the popular database systems, including MySQL, PostgreSQL, Oracle, Sybase, SQLite, and ODBC-compliant databases.
Example 1-4 shows MySQL database query - book title, year, ISBN - drop library.sql into MySQL after you create the library database, and have the sample database at your disposal for testing out the following code sample as well as the related samples in Chapter 8 - code in Example 1-4 connects to database, issues a query to retrieve all available books (with the WHERE clause), and produces a table as output for all returned results through a while loop - database-provided dynamic content drives the news, blog, and ecommerce sites at the heart of the Web - more in Chapter 8

Example 1-4 booklist.php
...

Graphics
p13 - Easily create and manipulate images using GD extension. Example 1-5 provides text-entry field that lets the user specify the text for a button. It takes an empty button image file, and on it centers the text passed as the GET parameter 'message'. The result is then sent back to the browser as a PNG image.

Example 1-5 - Dynamic buttons - graphic_example.php

You can use GD to dynamically resize images, produce graphs, and much more. PHP also has several extensions to generate documents in Adobe’s popular PDF format - Chapter 9 covers dynamic image generation in depth - Chapter 10 provides instruction on how to create Adobe PDF files


CHAPTER 2 - Language Basics

p15 - Chapter provides whirlwind tour of core PHP language - covering data types, variables, operators, and flow control statements - PHP strongly influenced by other programming languages, such as Perl and C - should be easy to pick up - if PHP first language don't panic - we build up from basics

Lexical Structure
Case Sensitivity
Statements and Semicolons
Whitespace and Line Breaks
Comments

Literals
p20 - 2001
0xFE
1.4142
"Hello World"
'Hi'
true
null

Identifiers
An identifier is simply a name used to name variables, functions, constants, and classes - first character of an identifier must be an ASCII letter or underscore character (_) or between ASCII 0x7F and ASCII 0xFF - after the initial character, these characters and the digits 0–9 are valid - variable names always begin with a dollar sign ($) and are case-sensitive - function and class names are not case-sensitive - class name stdClass is reserved - a constant is an identifier for a simple value; only scalar values—Boolean, integer, double, and string can be constants - Once set, the value of a constant cannot change - referred to by their identifiers and are set using the define() function
define('PUBLISHER', "O'Reilly & Associates");
echo PUBLISHER;

Keywords
p21 - A keyword (or reserved word) is a word set aside by the language for its core functionality - you cannot give a variable, function, class, or constant the same name as a keyword - we cannot use an identifier that is the same as a built-in PHP function - complete list see APPENDIX - List of Keywords php.net

PHP Keywords - case-insensitive
__halt_compiler() abstract and array() as - break callable (as of PHP 5.4) case catch class
clone const continue declare default - die() do echo else elseif
empty() enddeclare endfor endforeach endif - endswitch endwhile eval() exit() extends
final finally (as of PHP 5.5) for foreach function - global goto (as of PHP 5.3) if implements include
include_once instanceof insteadof (as of PHP 5.4) interface isset() - list() namespace (as of PHP 5.3) new or print

private protected public require require_once - return static switch throw trait (as of PHP 5.4)
try unset() use var while - xor yield (as of PHP 5.5) = 67 keywords :-)

Compile-time constants - case-insensitive
__CLASS__ __DIR__ (as of PHP 5.3) __FILE__ __FUNCTION__ __LINE__
__METHOD__ __NAMESPACE__ (as of PHP 5.3) __TRAIT__ (as of PHP 5.4) = 8 compile-time constants :-)

Data Types

Integers
p22 - whole numbers - typically extends from −2,147,483,648 to +2,147,483,647 - can be written in decimal, octal, or hexadecimal - octal numbers consist of a leading 0 and a sequence of digits from 0 to 7
0755 // decimal 493
+010 // decimal 8
Hexadecimal values begin with 0x, followed by a sequence of digits (0–9) or letters (A–F)
0xFF // decimal 255
0x10 // decimal 16
-0xDAD1 // decimal −56017
If you try to store a variable that is too large to be stored as an integer or is not a whole number, it will automatically be turned into a floating-point number. Use the is_int() function (or its is_integer() alias) to test whether a value is an integer:
if (is_int($x)) {
// $x is an integer
}

Floating-Point Numbers
p23 - ...

Strings







<<< Current Working Area



Booleans
Arrays
Objects
Resources
Callbacks
NULL
Variables
Variable Variables
Variable References
Variable Scope
Garbage Collection

Expressions and Operators

p34 -

Flow-Control Statements

p47 - if - elseif - else
switch
while
for
foreach
try...catch
declare
exit and return
goto

Including Code
Embedding PHP in Web Pages
Standard (XML) Style
SGML Style
ASP Style
Script Style
Echoing Content Directly - p61







CHAPTER 3 - Functions

p63 -


CHAPTER 4 - Strings

p77 -

Example 4-1 php
Example 4-2 php


CHAPTER 5 - Arrays

p119 -


Example 5-1 - Building a table with the iterator functions
Example 5-2 - Searching an array
Example 5-3 - Sorting arrays
Example 5-4 - State debugger
Example 5-5 - Iterator interface


CHAPTER 6 - Objects

p147 -

Example 6-5 next.php


CHAPTER 7 - Web Techniques

p173 -


Example 7-1 - The chunkify form - chunkify.html
Example 7-3 - A self-processing temperature-conversion page - temp.php
Example 7-4 - Temperature conversion using the GET method - temp2.php
Example 7-5 - Temperature conversion with a sticky form - sticky_form.php
Example 7-6 - Multiple selection values with a select box - select_array.php
Example 7-7 - Multiple selection values in checkboxes - checkbox_array.php
Example 7-8 - Sticky multivalued checkboxes - checkbox_array2.php
Example 7-9 - Form validation - data_validation.php
Example 7-10 - Preference selection - colors.php
Example 7-11 - Setting preferences with cookies - prefs.php
Example 7-12 - Using the color preferences with cookies - prefs_demo.php
Example 7-13 - Setting preferences with sessions - prefs_session.php
Example 7-14 - Using preferences from sessions - prefs_session_demo.php
Example 7-15 - Saving state across visits - save_state.php


CHAPTER 8 - Databases

p203 - ...

Using PHP to Access a Database

Example 8-1 - The try...catch code structure
Example 8-2. SQLite library authors table


CHAPTER 9 - Graphics

p229 - ...

GD enabled?

Example 9-1 - Example Page
Example 9-2 black.php -

GD - php.net - button.php

Creating An Image With the PHP GD Library - png_image.png


CHAPTER 10 - PDF

p251 -

Example 10-1 - “Hello Out There!” in PDF
Example 10-2 - Demonstrating coordinates and line management


CHAPTER 11 - XML

p269 -


CHAPTER 12 - Security

p289 -


CHAPTER 13 - Application Techniques

p309 -


CHAPTER 14 - PHP on Disparate Platforms

p329 -


CHAPTER 15 - Web Services

p337 -


CHAPTER 16 - Debugging PHP

p349 -


CHAPTER 17 - Dates and Times

p359 -


APPENDIX - Function Reference

p363 - ...


Alphabetical Listing of PHP Functions

p372 - abs ... zend_version p490


Index

p491 - Symbols ... A ... Z p514

About the Authors
p514 - ...

Colophon
p516 ... end of book p516


Books

PHP

PHP: The Good Parts - Peter B McIntyre - O'Reilly - 148 Pages - First Edition April 2010

PHP and MySQL Web Development - Luke Welling, Laura Thompson - Fourth Edition Copyright © 2009 (Fifth Edition ...) - Pearson Education, Inc. - 911 Pages

Programming PHP - Kevin Tatroe, Peter MacIntyre, and Rasmus Lerdorf - Third Edition Copyright © February 2013 - O'Reilly - 491 Pages





JavaScript

JavaScript: The Good Parts - David Crockford - O'Reilly - 170 Pages - May 2, Copyright © 2008





Other

Design Patterns - Elements of Reusable Object-Oriented Software - Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides - Addison-Wesley - 525 Pages - First Edition Copyright © January 15, 1995 - $ 38.70 - Amazon



Vocabularies

comprehensive - umfassend, inhaltsreich, umfangreich, übergreifend, global, flächendeckend, intimidating - einschüchternd, furchterregend
rather - eigentlich, lieber, eher, ziemlich, im Gegenteil, stattdessen, vielmehr, um genau zu sein, lieber als, sondern eher ...
top-notch - erstklassig


Notes


Learning JavaScript Design Patterns - Addy Osmani - Design Patterns - Anti-Patterns - Wikipedia - Recommended by Chris Heilmann - 2014-4-11 :-)
Chris Heilmann - TW 35.5K
JavaScript Patterns - Stoyan Stefanov - 236 Pages - O'Reilly September 2010
Maintainable JavaScript - Writing Readable Code - 242 Pages  - O'Reilly May 2012
JavaScript: The Good Parts - Unearthing the Excellence in JavaScript by Douglas Crockford - sys-con.com - SYS-CON Media TW 3.9K - 172 Pages - O'Reilly May 2008


Sessions


Session - 2014-4-10, Bln, 13:40-15:30 REGISTER_GLOBALS in php.ini removed since PHP 5.4 - 15:45-

Session 1 - 2014-4-8, Bln, 6:40-10:00=3:20 - 10:30-11:00=0:30 - 15:25-16:00=0:35 - 17:15-19:55=2:40 - 20:40-22:05=1:25 - 22:35-0:25=1:50 PP (Programming PHP) R LR WR HP + Examples u.a. Bücher ♡ = 3:20+0:30+0:35+2:40+1:25+1:50 = 10:20 total time

More coming soon :-)


Website counter

Copyright © 2014 by IDL Productions