PHP - Helion

ISBN: 978-13-012-6761-3
stron: 256, Format: ebook
Data wydania: 2013-12-26
Księgarnia: Helion
Cena książki: 8,40 zł
UWAGA: Ebook w JĘZYKU ANGIELSKIM, wydanie zaktualizowane 07-01-2014
"PHP", to skrót myślowy od "Składnia PHP, przykłady programów w PHP i techniki programowania w PHP". Podręcznik opisuje programowanie strukturalne (funkcje), programowanie obiektowe (klasy i obiekty). Przykłady:
- jak określić adresy IP odwiedzających
- jak stosować geolokację (by wiedzieć gdzie fizycznie są użytkownicy)
- jak budować interaktywne gry w PHP
- jak dynamicznie generować strony WWW
- jak obsługiwać formularze i pobierać dane od uzytkowników
i wiele innych, gotowych do zastosowania przykładowych kodów w PHP
UWAGA! Ebook w języku Angielskim
Osoby które kupowały "PHP", wybierały także:
- Tablice informatyczne. PHP7 19,67 zł, (5,90 zł -70%)
- PHP. Koduj czysto i czytelnie. Najlepsze rozwi 65,31 zł, (20,90 zł -68%)
- PHP i jQuery. Techniki zaawansowane. Wydanie II 65,31 zł, (20,90 zł -68%)
- PHP. Kurs video. Tworzenie własnego środowiska na podstawie wzorca MVC 119,00 zł, (53,55 zł -55%)
- Rzeczywistość wirtualna (VR) dla każdego - Aframe i HTML 5. VR w HTML 5 na każdym urządzeniu z Internetem! Wydanie II 24,90 zł, (12,45 zł -50%)
Spis treści
PHP eBook -- spis treści
UWAGA: EBOOK W JĘZYKU ANGIELSKIM
Książka zawiera opis wykrytego przez Autora błędu w PHP występującego w niektórych wersjach PHP 5. Opis błędu i sposoby unikania błędnych kodów (alternatywne rozwiązania w PHP) podano w dodatku (APPENDIX).
ENGLISH EDITION, updated 07-01-2014
CONTENTS:
CHAPTER 1: Introduction to the e-book edition
Similarities and differences: PHP vs. C/C++
What and how can PHP do for us?
What for? To get visitor’s IP, for example
What do I need for beginning?
How to use PHP?
Embedding PHP
Comments in PHP
How to use PHP interpreter online
Running PHP from the command line
Command line input (STDIN)
CHAPTER 2: PHP variables
Case sensitivity
Error messages and warnings
Data types in PHP
Using constants in PHP
Integer data type
Floating-point numbers
Bool type (Boolean values)
Null type variable and type checking in PHP
Dynamic variables
CHAPTER 3: Operators
Arithmetic operators
Assignment operator and combined operators
Pre / post - increment and decrement operators
Comparison operators
Logical operators
Base converting functions and bitwise operators
Operator precedence
Filtering mask with binary operators
CHAPTER 4: PHP Arrays, array constructor, array types in PHP
Numeric indexed arrays, runtime array size change
Associative arrays and string arrays
Character strings as 1D array
Mixed arrays
Multi-dimensional arrays, hash table
Array elements can be sorted
Internal pointer and some useful functions
CHAPTER 5: If we need conditional statements or loops
If statement (if-elseif-else) and switch-case statement
The while and do-while loops
The for and foreach loops
The break, continue and goto keywords
CHAPTER 6: Custom functions
Argument passing by value and using default values
Variable argument list
Argument passing by reference
Returning an array or modifying values by reference
Locals vs. globals
Math functions
Searching and sorting
Quick binary search
PHP runtime-created functions
Date and time
CHAPTER 7: Introduction to OOP
Properties
Creating an object (a class new instance)
Constructor
Destructor
Included and required file(s)
CHAPTER 8: Programming practice
Static methods
Declaring constants within classes
Magic constants
Static properties in use
Recommended OOP practice and The Gold Rule
CHAPTER 9: Object-oriented programming
Inheritance – first glance
Overriding class members
Final keyword and instanceof operator
Access levels before and after inheritance
Generating HTML page using PHP functions
Generating the same HTML page using classes and methods
A few words about PHP scope
Interfaces, abstract classes and traits
Abstract data types (ADT) and the abstract keyword
Traits
CHAPTER 10: Data input in PHP
How HTML forms work
Variables and superglobal PHP arrays
Processing forms in PHP
Simple form example and a little more about form processing
Intermixing HTML and PHP
Using PHP interpreter online and JavaScript codes
PHP intermixing with JavaScript, how it works
Information Feedback: Client-Server-Client-Server dialogue
The precise Real Time Clock in PHP
CHAPTER 11: PHP interaction with operating system and file system
PHP interaction with operating systems being system-dependent
Basic file-related functions
More about opening a file by fopen() function
SPLFileObject, SPLFileInfo objects
Directory – related functions
STDIN and STDOUT streams and piping
A simple way to place an image in PHP
How to create graphs and function plots in PHP
CHAPTER 12: Effective programming in PHP
Variable scope in PHP vs. JavaScript
Algorithm complexity and recursive functions
Fibonacci sequence and factorials
Programming errors
Type setting and casting to avoid some errors
CHAPTER 13: Using local storage in JavaScript and with PHP
Counting views in JavaScript on the client side
Single file PHP calculator
PHP Cookies
Creating Cookies in PHP
$_COOKIE[] array and $HTTP_COOKIE_VARS[] array
Deleting cookies
Checking a cookie value in JavaScript
Sessions
CHAPTER 14: Advanced object oriented programming
Using __set() and __get() methods
Property and function overloading
More about lambda functions and closures
Namespaces
Namespace aliases
CHAPTER 15: Data validation and error handling
Listing form variables
Error handling
Switching form On/Off using a single flag (the simplest validation)
Data validation on the client side (JavaScript)
Validation on the server side using PHP
The
Exception handling
CHAPTER 16: XML, TCP/IP and Real Time data processing
SimpleXML in PHP
XML processing in PHP
The DOM and SimpleXML examples
TCP/IP
How to evaluate real speed of our Client-Server feedback loop
Function call time measuring
Random numbers and a simple PHP game
CHAPTER 17: Simple examples
Shared operating memory in PHP
Login and password – why data encryption is needed
A few words about data encryption in PHP
APPENDIX
Polymorphism example
Converting relative path to absolute path
How to get visitor’s IP?
File uploading from user’s disk
Setting timeout on the client side and on the server side
Regular expressions – what it is and what for?
Creating and showing an image gallery
Drawing boxes by intermixing PHP, HTML and CSS
Drawing y = cos( x ) graph in PHP
Unicode in PHP
Simple geo-location based on IP
Some useful links
An ERROR in PHP5 discovered
BC Math functions vs. PHP operators
Pointer to an external process
This is the QUICK REFERENCE TO PHP for students, IT engineers and for all newcomers. Besides of numerous PHP examples this e-book contains also some simple JavaScript code snippets to show how to perform data processing on the client side by JavaScript and on the server side by PHP. Those are always the two alternative methods to select by programmers. So I have compared hereby some popular programming techniques being frequently used and providing complementary solutions. Because this e-book and these examples was written by and for programmers, PHP comes here with an extensive set of features and functions. The most interesting examples see:
* Information Feedback: Client-Server-Client-Server dialogue (CH 10, CH 16)
* Effective programming in PHP (CH 10)
* A simple way to place an image in PHP (CH 11)
* How to get visitor IP (APPENDIX)
* Algorithm complexity (CH 12)
FREE SAMPLE
Sometimes you can prefer to implement such type query in your PHP code. It is simple. The simple code below is working and it is ready to use.
// Adam Majczak: Geo-location Example
$ip='83.203.140.87'; // here you can use any valid IP
function AmCheckIP($ip) {
if(!filter_var($ip, FILTER_VALIDATE_IP)) {
throw new InvalidArgumentException("ERROR: IP not valid"); }
$answer=@file_get_contents('http://www.netip.de/search?query='.$ip);
if (empty($answer)) {
throw new InvalidArgumentException("Error: Geo-Location-Server connection failed."); }
$patterns=array();
$patterns["domain"] = '#Domain: (.*?) #i';
$patterns["country"] = '#Country: (.*?) #i';
$patterns["state"] = '#State/Region: (.*?)
$patterns["town"] = '#City: (.*?)
$ipInfo=array();
foreach ($patterns as $key => $pattern) {$ipInfo[$key] = preg_match($pattern, $answer, $value) && !empty($value[1]) ? $value[1] : 'not detected'; }
return $ipInfo;
}
print_r( AmCheckIP($ip) );
?>
// printout:
Array ([country] => FR - France [state] => Bourgogne [town] => Dijon)





