Introduction to PHP, Part 4, Second Edition
By Adam Majczak
()
About this ebook
The book describes: classes (continuation of the Part 2 and Part 3), interfaces, traits, tuples, namespaces, ADT, randomizing, HTML, PHP & JavaScript intermixing.
Read more from Adam Majczak
Introduction to PHP Rating: 3 out of 5 stars3/5Introduction to PHP, Part 1, Second Edition Rating: 0 out of 5 stars0 ratingsIntroduction to PHP, Part 2, Second Edition Rating: 0 out of 5 stars0 ratingsReference to PHP, Second Edition Rating: 0 out of 5 stars0 ratingsIntroduction to PHP, Part 5, Second Edition Rating: 0 out of 5 stars0 ratingsIntroduction to PHP, Part 3, Second Edition Rating: 0 out of 5 stars0 ratings
Related to Introduction to PHP, Part 4, Second Edition
Related ebooks
PHP for Beginners Rating: 0 out of 5 stars0 ratingsLearn PHP 8: Using MySQL, JavaScript, CSS3, and HTML5 Rating: 0 out of 5 stars0 ratingsPHP Examples, Part 2 Rating: 1 out of 5 stars1/5A concise guide to PHP MySQL and Apache Rating: 4 out of 5 stars4/5PHP Examples Part 3 Rating: 5 out of 5 stars5/5PHP Examples Part 4 Rating: 0 out of 5 stars0 ratingsHTML, CSS, Bootstrap, Php, Javascript and MySql: All you need to know to create a dynamic site Rating: 4 out of 5 stars4/5PHP MySQL Development of Login Modul: 3 hours Easy Guide Rating: 5 out of 5 stars5/5The PHP Workshop: Learn to build interactive applications and kickstart your career as a web developer Rating: 0 out of 5 stars0 ratings10 Lessons in Front-end Rating: 2 out of 5 stars2/5PHP & MySQL Practice It Learn It Rating: 3 out of 5 stars3/5Learn PHP Programming in 7Days: Ultimate PHP Crash Course For Beginners Rating: 3 out of 5 stars3/5Javascript Concepts: 1St Edition Rating: 0 out of 5 stars0 ratingsJava: Tips and Tricks to Programming Code with Java: Java Computer Programming, #2 Rating: 0 out of 5 stars0 ratingsP.H.P Simple C.R.U.D Design Rating: 4 out of 5 stars4/5Learn Javascript In 1 Hour Rating: 0 out of 5 stars0 ratingsOpenCart Tips and Tricks Rating: 0 out of 5 stars0 ratingsWeb Coding & Development All-in-One For Dummies Rating: 1 out of 5 stars1/5Quick JavaScript Learning In Just 3 Days: Fast-Track Learning Course Rating: 0 out of 5 stars0 ratingsJavaScript for the Business Developer Rating: 3 out of 5 stars3/5Learn Angular: Build a Todo App Rating: 0 out of 5 stars0 ratingsIntroduction to PHP, Part 3, Second Edition Rating: 0 out of 5 stars0 ratingsWb Development full course : from zero to web hero Rating: 0 out of 5 stars0 ratingsPHP Team Development Rating: 3 out of 5 stars3/5Progressive web app A Clear and Concise Reference Rating: 0 out of 5 stars0 ratingsFundamentals of Android App Development: Android Development for Beginners to Learn Android Technology, SQLite, Firebase and Unity Rating: 0 out of 5 stars0 ratingsLearn PHP: Learn PHP Programming in 4 hours! PHP for Beginners - Smart and Easy Ways to learn PHP & MySQL Rating: 4 out of 5 stars4/5HTML Forms & Interactive Elements: Or How to Poke a Zombie in the Eye: Undead Institute Rating: 0 out of 5 stars0 ratings
Programming For You
Python Programming : How to Code Python Fast In Just 24 Hours With 7 Simple Steps Rating: 4 out of 5 stars4/5Coding All-in-One For Dummies Rating: 4 out of 5 stars4/5Learn to Code. Get a Job. The Ultimate Guide to Learning and Getting Hired as a Developer. Rating: 5 out of 5 stars5/5HTML & CSS: Learn the Fundaments in 7 Days Rating: 4 out of 5 stars4/5Grokking Algorithms: An illustrated guide for programmers and other curious people Rating: 4 out of 5 stars4/5OneNote: The Ultimate Guide on How to Use Microsoft OneNote for Getting Things Done Rating: 1 out of 5 stars1/5SQL QuickStart Guide: The Simplified Beginner's Guide to Managing, Analyzing, and Manipulating Data With SQL Rating: 4 out of 5 stars4/5Hacking: Ultimate Beginner's Guide for Computer Hacking in 2018 and Beyond: Hacking in 2018, #1 Rating: 4 out of 5 stars4/5Excel : The Ultimate Comprehensive Step-By-Step Guide to the Basics of Excel Programming: 1 Rating: 5 out of 5 stars5/5Web Designer's Idea Book, Volume 4: Inspiration from the Best Web Design Trends, Themes and Styles Rating: 4 out of 5 stars4/5Python Projects for Beginners: A Ten-Week Bootcamp Approach to Python Programming Rating: 0 out of 5 stars0 ratingsPYTHON: Practical Python Programming For Beginners & Experts With Hands-on Project Rating: 5 out of 5 stars5/5Learn PowerShell in a Month of Lunches, Fourth Edition: Covers Windows, Linux, and macOS Rating: 0 out of 5 stars0 ratingsLinux: Learn in 24 Hours Rating: 5 out of 5 stars5/5Python: For Beginners A Crash Course Guide To Learn Python in 1 Week Rating: 4 out of 5 stars4/5C++ Learn in 24 Hours Rating: 0 out of 5 stars0 ratingsHTML in 30 Pages Rating: 5 out of 5 stars5/5Java for Beginners: A Crash Course to Learn Java Programming in 1 Week Rating: 5 out of 5 stars5/5Learn JavaScript in 24 Hours Rating: 3 out of 5 stars3/5SQL All-in-One For Dummies Rating: 3 out of 5 stars3/5Beginning Programming with Python For Dummies Rating: 3 out of 5 stars3/5Python: Learn Python in 24 Hours Rating: 4 out of 5 stars4/5Raspberry Pi Cookbook for Python Programmers Rating: 0 out of 5 stars0 ratings
Reviews for Introduction to PHP, Part 4, Second Edition
0 ratings0 reviews
Book preview
Introduction to PHP, Part 4, Second Edition - Adam Majczak
Introduction to PHP
Part IV
Adam Majczak
C. Adam Majczak, 2015, All Rights Reserved
Smashwords: Second English Edition
(improved and updated)
E-Edition, License Notes
This e-book is licensed for your personal use only. This e-book may not be re-sold or given away to others. To share this book with another person, please purchase an additional copy for each recipient.
While every precaution has been taken in the preparation of this book, the publisher and the author assume no responsibility for errors or omissions, or any for damages resulting from any use of the information contained herein.
ENGLISH EDITION
PART IV
CONTENTS:
Let’s take a look again (without HEREDOC)
CHAPTER 11: Classes, objects and traits in use
Generating HTML page using PHP classes
A few words about PHP scope
Interfaces
Abstract data types (ADT) and the abstract keyword
Polymorphism
Traits
Randomized numbers and strings
CHAPTER 12: Intermixing PHP and HTML, JavaScript, OS commands
Intermixing PHP and HTML
Using intermixed PHP and JavaScript codes
How to transfer data from PHP variable to JavaScript variable?
How to transfer data from JavaScript variable to PHP variable?
PHP intermixing with JavaScript, how it works?
Transferring data from PHP variables to JavaScript again
PHP interaction with operating system and file system
Pointing to an external process
Basic file-related functions
CHAPTER 13: Effective programming using functions and classes
Algorithm complexity and recursive functions
Fibonacci sequence and factorials
Programming errors
The is_datatype()
group
Better encapsulation: using __set() and __get() methods
Property and function overloading
More about lambda functions and closures
Namespaces
Namespace aliases
CHAPTER 14: A few advanced topics simply explained
A few words about error handling
Function call - time measuring
The NaN and Infinity errors
Exception handling
Shared operating memory in PHP
A few words about data encryption in PHP
Tuples in PHP
Let’s take a look again (without HEREDOC)
Let’s take a look at the previous example again to compare it with a new object-oriented version shown later.
Generating HTML page using PHP functions
(PHP code from the Part III repeated, excluding HEREDOC constructions used in previous version)
date_default_timezone_set('UTC');
// Generates the top of the page
function addHeader($page, $title) {
$page .= "
center\">$title
;
return $page;
}
// Generates the bottom of the page
function addFooter($page, $year, $copyright) {
$page .= "
";
return $page;
}
// Initialize the page variable
$page = '';
// Add the header to the page
$page = addHeader($page, 'Adam Majczak: PHP Script');
// Add something to the body of the page
$page .=
This page was generated with a PHP script
;
// Add the footer to the page
$page = addFooter($page, date('Y'), ' Adam Majczak.');
// Display the page
print $page;
?>
// printout:
Adam Majczak: PHP Script
This page was generated with a PHP script
© 2015 Adam Majczak.
This simple code generates the following HTML code:
center>This page was generated with a PHP scriptcenter>Adam Majczak: PHP Script
looking at a client browser window like this:
Pic. 16. The code in action (client browser).
CHAPTER 11: Classes, objects and traits in use
Generating HTML page using PHP classes
HTML codes can be generated using PHP functions or using PHP classes and objects. It is the time for a short review of PHP classes and objects in use. In the previous Chapter