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/5Reference to PHP, Second Edition Rating: 0 out of 5 stars0 ratingsIntroduction to PHP, Part 2, Second Edition Rating: 0 out of 5 stars0 ratingsIntroduction to PHP, Part 1, 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
Introduction to PHP, Part 5, Second Edition Rating: 0 out of 5 stars0 ratingsPHP Examples Part 4 Rating: 0 out of 5 stars0 ratingsPHP for Beginners 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 MySQL Development of Login Modul: 3 hours Easy Guide Rating: 5 out of 5 stars5/5Flash with Drupal Rating: 0 out of 5 stars0 ratingsP.H.P Simple C.R.U.D Design Rating: 4 out of 5 stars4/5PHP Examples Part 3 Rating: 5 out of 5 stars5/5Web Coding & Development All-in-One For Dummies Rating: 1 out of 5 stars1/5PHP & MySQL Practice It Learn It Rating: 3 out of 5 stars3/5Learn Javascript In 1 Hour Rating: 0 out of 5 stars0 ratingsLearn JSP in 24 Hours Rating: 0 out of 5 stars0 ratingsLearn 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 ratingsThe PHP Workshop: Learn to build interactive applications and kickstart your career as a web developer Rating: 0 out of 5 stars0 ratingsQuick JavaScript Learning In Just 3 Days: Fast-Track Learning Course Rating: 0 out of 5 stars0 ratingsDjango Admin Cookbook Rating: 0 out of 5 stars0 ratingsGetting started with php & mysql: Professional training 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/510 Lessons in Front-end Rating: 2 out of 5 stars2/5Multi-Tier Application Programming with PHP: Practical Guide for Architects and Programmers Rating: 0 out of 5 stars0 ratingsLearn ASP.NET Core MVC - Be Ready Next Week Using Visual Studio 2017 Rating: 5 out of 5 stars5/5ASP.NET Application Development Fundamentals Rating: 0 out of 5 stars0 ratingsOpenCart Tips and Tricks Rating: 0 out of 5 stars0 ratingsIntroduction to PHP, Part 3, Second Edition Rating: 0 out of 5 stars0 ratingsAJAX Interview Questions, Answers, and Explanations: AJAX Certification Review Rating: 0 out of 5 stars0 ratingsProgressive web app A Clear and Concise Reference Rating: 0 out of 5 stars0 ratingsjQuery 1.3 with PHP Rating: 0 out of 5 stars0 ratingsPHP Team Development Rating: 3 out of 5 stars3/5
Programming For You
HTML & CSS: Learn the Fundaments in 7 Days Rating: 4 out of 5 stars4/5Coding All-in-One For Dummies Rating: 4 out of 5 stars4/5SQL All-in-One For Dummies Rating: 3 out of 5 stars3/5Python: For Beginners A Crash Course Guide To Learn Python in 1 Week Rating: 4 out of 5 stars4/5Learn PowerShell in a Month of Lunches, Fourth Edition: Covers Windows, Linux, and macOS Rating: 0 out of 5 stars0 ratingsSQL QuickStart Guide: The Simplified Beginner's Guide to Managing, Analyzing, and Manipulating Data With SQL 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/5Python Programming : How to Code Python Fast In Just 24 Hours With 7 Simple Steps Rating: 4 out of 5 stars4/5SQL: For Beginners: Your Guide To Easily Learn SQL Programming in 7 Days Rating: 5 out of 5 stars5/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/5Grokking Algorithms: An illustrated guide for programmers and other curious people Rating: 4 out of 5 stars4/5Python QuickStart Guide: The Simplified Beginner's Guide to Python Programming Using Hands-On Projects and Real-World Applications Rating: 0 out of 5 stars0 ratingsPython Projects for Beginners: A Ten-Week Bootcamp Approach to Python Programming Rating: 0 out of 5 stars0 ratingsModern C++ for Absolute Beginners: A Friendly Introduction to C++ Programming Language and C++11 to C++20 Standards Rating: 0 out of 5 stars0 ratingsProgramming Arduino: Getting Started with Sketches Rating: 4 out of 5 stars4/5Problem Solving in C and Python: Programming Exercises and Solutions, Part 1 Rating: 5 out of 5 stars5/5PYTHON: Practical Python Programming For Beginners & Experts With Hands-on Project Rating: 5 out of 5 stars5/5
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