Book description
Dive into the world of PHP programming and algorithmic thinking with this comprehensive course designed for beginners. Learn the essentials of PHP and build a strong foundation in algorithmic concepts.
Key Features
- Understand how computers work and the basics of programming
- Learn to use PHP and IDEs, and master variables, constants, operators, and control structures
- Develop skills in manipulating data structures, while learning how to create and use subprograms
Book Description
Begin your journey into PHP programming and algorithmic thinking with a structured, detailed course that takes you from understanding the basic components of a computer to mastering complex decision control and loop structures. Each chapter builds on the previous one, starting with an introduction to how computers work and gradually progressing to more complex topics like decision control structures, loop structures, arrays, and subprograms.
You'll start with foundational concepts such as variables, constants, and operators, before diving into more advanced topics like manipulating strings, handling input and output, and developing complex mathematical expressions. The course emphasizes practical application, guiding you through the use of Visual Studio Code, integrated development environments, and essential software packages.
By the end of this book, you will have a solid understanding of PHP programming and algorithmic thinking, enabling you to write efficient code, develop your own subprograms, and utilize various control structures and arrays effectively. This course is tailored for beginners, ensuring a smooth learning curve with tips, tricks, and exercises to reinforce your knowledge, and prepare you with the necessary skills needed to be a programmer.
What you will learn
- Utilize PHP for various programming tasks
- Implement control structures, loops, and arrays in code
- Develop and use subprograms for modular programming
- Apply object-oriented principles and manage files in PHP
- Analyze and debug PHP code effectively
- Integrate PHP with databases for dynamic web development
Who this book is for
This course is ideal for complete beginners with no prior programming experience. It is also perfect for students, self-taught programmers, and professionals looking to refresh their knowledge of PHP and algorithmic thinking. Educators seeking to enhance their teaching methods and hobbyists wanting to explore programming as a new skill will also benefit greatly. Basic computer literacy is recommended, but no specific prerequisites are required.
Table of contents
- Table of Contents
- Preface
- Part I Introductory Knowledge
-
Part II Getting Started with PHP
-
Chapter 4 Introduction to Basic Algorithmic Concepts
- 4.1 What is an Algorithm?
- 4.2 The Algorithm for Making a Cup of Tea
- 4.3 Properties of an Algorithm
- 4.4 Okay About Algorithms. But What is a Computer Program Anyway?
- 4.5 The Three Parties!
- 4.6 The Three Main Stages Involved in Creating an Algorithm
- 4.7 Flowcharts
- 4.8 What are ”Reserved Words”?
- 4.9 What is the Difference Between a Statement and a Command?
- 4.10 What is Structured Programming?
- 4.11 The Three Fundamental Control Structures
- 4.12 Your First PHP Script
- 4.13 What is the Difference Between a Syntax Error, a Logic Error, and a Runtime Error?
- 4.14 What “Debugging” Means
- 4.15 Commenting Your Code
- 4.16 User-Friendly Programs and Scripts
- 4.17 Review Questions: True/False
- 4.18 Review Questions: Multiple Choice
-
Chapter 5 Variables and Constants
- 5.1 What is a Variable?
- 5.2 What is a Constant?
- 5.3 How Many Types of Variables and Constants Exist?
- 5.4 Rules and Conventions for Naming Variables and Constants in PHP
- 5.5 What Does the Phrase “Declare a Variable” Mean?
- 5.6 How to Declare Variables in PHP
- 5.7 How to Declare Constants in PHP
- 5.8 Review Questions: True/False
- 5.9 Review Questions: Multiple Choice
- 5.10 Review Exercises
- Chapter 6 Handling Input and Output
- Chapter 7 Operators
- Chapter 8 Trace Tables
- Chapter 9 Using Visual Studio Code
- Review in “Getting Started with PHP”
-
Chapter 4 Introduction to Basic Algorithmic Concepts
-
Part III Sequence Control Structures
-
Chapter 10 Introduction to Sequence Control Structures
-
10.1 What is the Sequence Control Structure?
- Exercise 10.1-1 Calculating the Area of a Rectangle
- Exercise 10.1-2 Calculating the Area of a Circle
- Exercise 10.1-3 Where is the Car? Calculating Distance Traveled
- Exercise 10.1-4 Kelvin to Fahrenheit
- Exercise 10.1-5 Calculating Sales Tax
- Exercise 10.1-6 Calculating a Sales Discount
- Exercise 10.1-7 Calculating a Sales Discount and Tax
- 10.2 Review Exercises
-
10.1 What is the Sequence Control Structure?
- Chapter 11 Manipulating Numbers
- Chapter 12 Complex Mathematical Expressions
- Chapter 13 Exercises With a Quotient and a Remainder
- Chapter 14 Manipulating Strings
- Review in “Sequence Control Structures”
-
Chapter 10 Introduction to Sequence Control Structures
-
Part IV Decision Control Structures
-
Chapter 15 Making Questions
- 15.1 Introduction
- 15.2 What is a Boolean Expression?
- 15.3 How to Write Simple Boolean Expressions
- 15.4 Logical Operators and Complex Boolean Expressions
- 15.5 Assigning the Result of a Boolean Expression to a Variable
- 15.6 What is the Order of Precedence of Logical Operators?
- 15.7 What is the Order of Precedence of Arithmetic, Comparison, and Logical Operators?
- 15.8 How to Negate Boolean Expressions
- 15.9 Review Questions: True/False
- 15.10 Review Questions: Multiple Choice
- 15.11 Review Exercises
- Chapter 16 The Single-Alternative Decision Structure
- Chapter 17 The Dual-Alternative Decision Structure
- Chapter 18 The Multiple-Alternative Decision Structure
- Chapter 19 The Case Decision Structure
- Chapter 20 Nested Decision Control Structures
- Chapter 21 More about Flowcharts with Decision Control Structures
-
Chapter 22 Tips and Tricks with Decision Control Structures
- 22.1 Introduction
- 22.2 Choosing a Decision Control Structure
- 22.3 Streamlining the Decision Control Structure
- 22.4 Logical Operators – to Use, or not to Use: That is the Question!
- 22.5 Merging Two or More Single-Alternative Decision Structures
- 22.6 Replacing Two Single-Alternative Decision Structures with a Dual-Alternative One
- 22.7 Put the Boolean Expressions Most Likely to be True First
- 22.8 Why is Code Indentation so Important?
- 22.9 Review Questions: True/False
- 22.10 Review Questions: Multiple Choice
- 22.11 Review Exercises
-
Chapter 23 More with Decision Control Structures
-
23.1 Simple Exercises with Decision Control Structures
- Exercise 23.1-1 Is it an Integer?
- Exercise 23.1-2 Validating Data Input and Finding Odd and Even Numbers
- Exercise 23.1-3 Where is the Tollkeeper?
- Exercise 23.1-4 The Most Scientific Calculator Ever!
- Exercise 23.1-5 Converting Gallons to Liters, and Vice Versa
- Exercise 23.1-6 Converting Gallons to Liters, and Vice Versa (with Data Validation)
- 23.2 Finding Minimum and Maximum Values with Decision Control Structures
- 23.3 Decision Control Structures in Solving Mathematical Problems
-
23.4 Exercises with Series of Consecutive Ranges of Values
- Exercise 23.4-1 Calculating the Discount
- Exercise 23.4-2 Validating Data Input and Calculating the Discount
- Exercise 23.4-3 Sending a Parcel
- Exercise 23.4-4 Finding the Values of y
- Exercise 23.4-5 Progressive Rates and Electricity Consumption
- Exercise 23.4-6 Progressive Rates and Text Messaging Services
- 23.5 Exercises of a General Nature with Decision Control Structures
- 23.6 Boolean Expressions Reference and Handy Tips
- 23.7 Review Exercises
-
23.1 Simple Exercises with Decision Control Structures
- Review in “Decision Control Structures”
-
Chapter 15 Making Questions
-
Part V Loop Control Structures
- Chapter 24 Introduction to Loop Control Structures
-
Chapter 25 Pre-Test, Mid-Test and Post-Test Loop Structures
-
25.1 The Pre-Test Loop Structure
- Exercise 25.1-1 Designing the Flowchart and Counting the Total Number of Iterations
- Exercise 25.1-2 Counting the Total Number of Iterations
- Exercise 25.1-3 Counting the Total Number of Iterations
- Exercise 25.1-4 Counting the Total Number of Iterations
- Exercise 25.1-5 Finding the Sum of Four Numbers
- Exercise 25.1-6 Finding the Sum of Odd Numbers
- Exercise 25.1-7 Finding the Sum of N Numbers
- Exercise 25.1-8 Finding the Sum of an Unknown Quantity of Numbers
- Exercise 25.1-9 Finding the Product of 20 Numbers
-
25.2 The Post-Test Loop Structure
- Exercise 25.2-1 Designing the Flowchart and Counting the Total Number of Iterations
- Exercise 25.2-2 Counting the Total Number of Iterations
- Exercise 25.2-3 Designing the Flowchart and Counting the Total Number of Iterations
- Exercise 25.2-4 Counting the Total Number of Iterations
- Exercise 25.2-5 Finding the Product of N Numbers
- 25.3 The Mid-Test Loop Structure
- 25.4 Review Questions: True/False
- 25.5 Review Questions: Multiple Choice
- 25.6 Review Exercises
-
25.1 The Pre-Test Loop Structure
-
Chapter 26 Definite Loops
-
26.1 The for statement
- Exercise 26.1-1 Creating the Trace Table
- Exercise 26.1-2 Creating the Trace Table
- Exercise 26.1-3 Counting the Total Number of Iterations
- Exercise 26.1-4 Finding the Sum of Four Numbers
- Exercise 26.1-5 Finding the Square Roots from 0 to N
- Exercise 26.1-6 Finding the Sum of 1 + 2 + 3 + … + 100
- Exercise 26.1-7 Finding the Product of 2 × 4 × 6 × 8 × 10
- Exercise 26.1-8 Finding the Sum of 22 + 42 + 62 + … (2N)2
- Exercise 26.1-9 Finding the Sum of 33 + 66 + 99 + … (3N)3N
- Exercise 26.1-10 Finding the Average Value of Positive Numbers
- Exercise 26.1-11 Counting the Vowels
- 26.2 Rules that Apply to For-Loops
- 26.3 Review Questions: True/False
- 26.4 Review Questions: Multiple Choice
- 26.5 Review Exercises
-
26.1 The for statement
- Chapter 27 Nested Loop Control Structures
- Chapter 28 More about Flowcharts with Loop Control Structures
-
Chapter 29 Tips and Tricks with Loop Control Structures
- 29.1 Introduction
- 29.2 Choosing a Loop Control Structure
- 29.3 The “Ultimate” Rule
- 29.4 Breaking Out of a Loop
- 29.5 Cleaning Out Your Loops
- 29.6 Endless Loops and How to Stop Them
- 29.7 The “From Inner to Outer” Method
- 29.8 Review Questions: True/False
- 29.9 Review Questions: Multiple Choice
- 29.10 Review Exercises
-
Chapter 30 More with Loop Control Structures
-
30.1 Simple Exercises with Loop Control Structures
- Exercise 30.1-1 Counting the Numbers According to Which is Greater
- Exercise 30.1-2 Counting the Numbers According to Their Digits
- Exercise 30.1-3 How Many Numbers Fit in a Sum
- Exercise 30.1-4 Finding the Total Number of Positive Integers
- Exercise 30.1-5 Iterating as Many Times as the User Wishes
- Exercise 30.1-6 Finding the Sum of the Digits
- 30.2 Exercises with Nested Loop Control Structures
- 30.3 Data Validation with Loop Control Structures
- 30.4 Finding Minimum and Maximum Values with Loop Control Structures
-
30.5 Using Loop Control Structures to Solve Mathematical Problems
- Exercise 30.5-1 Calculating the Area of as Many Triangles as the User Wishes
- Exercise 30.5-2 Finding x and y
- Exercise 30.5-3 The Russian Multiplication Algorithm
- Exercise 30.5-4 Finding the Number of Divisors
- Exercise 30.5-5 Is the Number a Prime?
- Exercise 30.5-6 Finding all Prime Numbers from 1 to N
- Exercise 30.5-7 Heron's Square Root
- Exercise 30.5-8 Calculating π
- Exercise 30.5-9 Approximating a Real with a Fraction
- 30.6 Exercises of a General Nature with Loop Control Structures
- 30.7 Review Questions: True/False
- 30.8 Review Exercises
-
30.1 Simple Exercises with Loop Control Structures
- Review in “Loop Control Structures”
-
Part VI Arrays in PHP
-
Chapter 31 One-Dimensional Arrays
- 31.1 Introduction
- 31.2 What is an Array?
- 31.3 Creating One-Dimensional Arrays in PHP
- 31.4 How to Get Values from a One-Dimensional Array
- 31.5 How to Alter the Value of an Array Element
- 31.6 How to Iterate Through a One-Dimensional Array
-
31.7 How to Add User-Entered Values to a One-Dimensional Array
- Exercise 31.7-1 Displaying Words in Reverse Order
- Exercise 31.7-2 Displaying Positive Numbers in Reverse Order
- Exercise 31.7-3 Finding the Average Value
- Exercise 31.7-4 Displaying Reals Only
- Exercise 31.7-5 Displaying Elements with Odd-Numbered Indexes
- Exercise 31.7-6 Displaying Even Numbers in Odd–Numbered Index Positions
- 31.8 What is an Map?
- 31.9 Creating Associative Arrays in PHP
- 31.10 How to Get a Value from an Associative Array
- 31.11 How to Alter the Value of an Element of an Associative Array
- 31.12 How to Iterate Through an Associative Array
- 31.13 Review Questions: True/False
- 31.14 Review Questions: Multiple Choice
- 31.15 Review Exercises
-
Chapter 32 Two-Dimensional Arrays
- 32.1 Creating Two-Dimensional Arrays in PHP
- 32.2 How to Get Values from Two-Dimensional Arrays
- 32.3 How to Iterate Through a Two-Dimensional Array
- 32.4 How to Add User-Entered Values to a Two-Dimensional Array
- 32.5 What's the Story on Variables $i and $j?
- 32.6 Square Matrices
- 32.7 Review Questions: True/False
- 32.8 Review Questions: Multiple Choice
- 32.9 Review Exercises
-
Chapter 33 Tips and Tricks with Arrays
- 33.1 Introduction
- 33.2 Processing Each Row Individually
- 33.3 Processing Each Column Individually
- 33.4 How to Use More Than One Arrays in a Script
- 33.5 Creating a One-Dimensional Array from a Two-Dimensional Array
- 33.6 Creating a Two-Dimensional Array from a One-Dimensional Array
- 33.7 Useful Array Functions (Subprograms)
- 33.8 Review Questions: True/False
- 33.9 Review Questions: Multiple Choice
- 33.10 Review Exercises
-
Chapter 34 More with Arrays
-
34.1 Simple Exercises with Arrays
- Exercise 34.1-1 Creating an Array that Contains the Average Values of its Neighboring Elements
- Exercise 34.1-2 Creating an Array with the Greatest Values
- Exercise 34.1-3 Merging One-Dimensional Arrays
- Exercise 34.1-4 Creating Two Arrays – Separating Positive from Negative Values
- Exercise 34.1-5 Creating an Array with Those who Contain Digit 5
- 34.2 Data Validation with Arrays
-
34.3 Finding Minimum and Maximum Values in Arrays
- Exercise 34.3-1 Which Depth is the Greatest?
- Exercise 34.3-2 Which Lake is the Deepest?
- Exercise 34.3-3 Which Lake, in Which Country, Having Which Average Area, is the Deepest?
- Exercise 34.3-4 Which Students Have got the Greatest Grade?
- Exercise 34.3-5 Finding the Minimum Value of a Two-Dimensional Array
- Exercise 34.3-6 Finding the City with the Coldest Day
- Exercise 34.3-7 Finding the Minimum and the Maximum Value of Each Row
-
34.4 Sorting Arrays
- Exercise 34.4-1 The Bubble Sort Algorithm – Sorting One-Dimensional Arrays with Numeric Values
- Exercise 34.4-2 Sorting One-Dimensional Arrays with Alphanumeric Values
- Exercise 34.4-3 Sorting One-Dimensional Arrays While Preserving the Relationship with a Second Array
- Exercise 34.4-4 Sorting Last and First Names
- Exercise 34.4-5 Sorting a Two-Dimensional Array
- Exercise 34.4-6 The Modified Bubble Sort Algorithm – Sorting One-Dimensional Arrays
- Exercise 34.4-7 The Selection Sort Algorithm – Sorting One-Dimensional Arrays
- Exercise 34.4-8 Sorting One-Dimensional Arrays While Preserving the Relationship with a Second Array
- Exercise 34.4-9 The Insertion Sort Algorithm – Sorting One-Dimensional Arrays
- Exercise 34.4-10 The Three Worst Elapsed Times
-
34.5 Searching Elements in Arrays
- Exercise 34.5-1 The Linear Search Algorithm – Searching in a One-Dimensional Array that may Contain the Same Value Multiple Times
- Exercise 34.5-2 Display the Last Names of All Those People Who Have the Same First Name
- Exercise 34.5-3 The Linear Search Algorithm – Searching in a Two-Dimensional Array that May Contain the Same Value Multiple Times
- Exercise 34.5-4 The Linear Search Algorithm – Searching in a One-Dimensional Array that Contains Unique Values
- Exercise 34.5-5 Searching for a Social Security Number
- Exercise 34.5-6 The Linear Search Algorithm – Searching in a Two-Dimensional Array that Contains Unique Values
- Exercise 34.5-7 Checking if a Value Exists in all Columns
- Exercise 34.5-8 The Binary Search Algorithm – Searching in a Sorted One-Dimensional Array
- Exercise 34.5-9 Display all the Historical Events for a Country
- Exercise 34.5-10 Searching in Each Column of a Two-Dimensional Array
-
34.6 Exercises of a General Nature with Arrays
- Exercise 34.6-1 On Which Days was There a Possibility of Snow?
- Exercise 34.6-2 Was There Any Possibility of Snow?
- Exercise 34.6-3 In Which Cities was There a Possibility of Snow?
- Exercise 34.6-4 Display from Highest to Lowest Grades by Student, and in Alphabetical Order
- Exercise 34.6-5 Archery at the Summer Olympics
- Exercise 34.6-6 The Five Best Scorers
- Exercise 34.6-7 Counting the Frequency of Vowels
- 34.7 Review Questions: True/False
- 34.8 Review Exercises
-
34.1 Simple Exercises with Arrays
- Review in “Arrays in PHP”
-
Chapter 31 One-Dimensional Arrays
-
Part VII Subprograms
- Chapter 35 Introduction to Subprograms
-
Chapter 36 User-Defined Subprograms
- 36.1 Subprograms that Return a Value
- 36.2 How to Make a Call to a Function
- 36.3 Subprograms that Return no Values
- 36.4 How to Make a Call to a void Function
- 36.5 Formal and Actual Arguments
- 36.6 How Does a Function Execute?
- 36.7 How Does a void Function Execute?
- 36.8 Review Questions: True/False
- 36.9 Review Exercises
-
Chapter 37 Tips and Tricks with Subprograms
- 37.1 Can Two Subprograms use Variables of the Same Name?
- 37.2 Can a Subprogram Call Another Subprogram?
- 37.3 Passing Arguments by Value and by Reference
- 37.4 Passing and/or Returning an Array
- 37.5 Default Argument Values (Optional Arguments) and Named Arguments
- 37.6 The Scope of a Variable
- 37.7 Converting Parts of Code into Subprograms
- 37.8 Recursion
- 37.9 Review Questions: True/False
- 37.10 Review Exercises
- Chapter 38 More with Subprograms
- Review in “Subprograms”
-
Part VIII Object-Oriented Programming
-
Chapter 39 Introduction to Object-Oriented Programming
- 39.1 What is Object-Oriented Programming?
- 39.2 Classes and Objects in PHP
- 39.3 The Constructor and the Keyword $this
- 39.4 Passing Initial Values to the Constructor
- 39.5 Getter and Setter Methods
- 39.6 Can a Method Call Another Method of the Same Class?
- 39.7 Class Inheritance
- 39.8 Review Questions: True/False
- 39.9 Review Exercises
- Review in “Object-Oriented Programming”
-
Chapter 39 Introduction to Object-Oriented Programming
-
Part IX Files
- Chapter 40 Introduction to Files
-
Chapter 41 More with Files
-
41.1 Exercises of a General Nature with Files
- Exercise 41.1-1 Calculating the Sum of 10 Numbers
- Exercise 41.1-2 Calculating the Average Value of an Unknown Quantity of Numbers
- Exercise 41.1-3 Finding Minimum and Maximum Values
- Exercise 41.1-4 Concatenating Files
- Exercise 41.1-5 Searching in a File
- Exercise 41.1-6 Combining Files with Subprograms
- 41.2 Review Exercises
-
41.1 Exercises of a General Nature with Files
- Review in “Files”
- Some Final Words from the Author
Product information
- Title: PHP and Algorithmic Thinking for the Complete Beginner
- Author(s):
- Release date: June 2024
- Publisher(s): Packt Publishing
- ISBN: 9781836209379
You might also like
book
C++ and Algorithmic Thinking for the Complete Beginner
Dive into the essentials of C++ and algorithmic thinking with this book. This comprehensive guide is …
book
Java and Algorithmic Thinking for the Complete Beginner
Dive into the world of Java and algorithmic thinking with this book. This comprehensive guide for …
book
PHP by Example: A Practical Guide to Creating Web Applications with PHP
Learn to create web applications in PHP with minimal previous experience. This book is a practical …
book
C# and Algorithmic Thinking for the Complete Beginner
Dive into the world of C# and algorithmic thinking with Aristides Bouras's comprehensive guide for complete …