Welcome to the PHP tutorial! This PHP tutorial helps you learn how to develop dynamic websites and web applications using PHP from scratch.
PHP is one of the most popular programming languages for web development.
PHP allows you to develop various web applications, including blogs, content management systems (CMS), and online stores.
Section 2. PHP Fundamentals
- Syntax – introduce you to the basic PHP syntax, including sensitivity, statements, whitespace, and linebreak.
- Variables – show you how to use variables to store data in PHP.
- Constants – define constants that hold a value that doesn’t change throughout the script.
- Comments – learn how to document your code effectively using comments.
- var_dump – learn how to dump the information about a variable.
Section 3. PHP Types
- Data types – give you a quick overview of PHP types, including scalar types, compound types, and special types.
- Boolean – learn how to represent a truthy value using the boolean type.
- Integer – explain to you how to work with integers in PHP.
- Float – guide you on how to represent floating-point numbers.
- String – learn about various forms of strings in PHP, including single-quoted and double-quoted strings.
- Null – introduce to you the NULL type and how to check if a variable is NULL or not.
Section 4. Operators
This section cover the most commonly used operators in PHP including logical and comparison operators.
- Assignment operators – learn about the most commonly used assignment operators effectively.
- Comparison operators – introduce to you the comparison operators that allow you to compare two values of the same or different types.
- Logical AND operator (&&) – show you how to use the logical AND operator to build complex logical expressions.
- Logical OR operator (||) – learn how to use the logical OR operator to form complex logical expressions.
- Logical NOT operator (!) – learn how to negate a Boolean expression.
- Operators – explain to you the available operators in PHP and help you apply them effectively.
Section 5. Control flow
- if – learn how to execute a code block based on a condition.
- if-else – show you how to run a code block if a condition is
trueand another code block if the condition is
- if-elseif – show you how to execute the corresponding code block based on multiple conditions.
- Ternary operator – guide you on using the ternary operator to make your code shorter and more readable.
- switch – learn how to use the switch statement effectively.
- for – execute a code block a fixed number of times.
- while – explain to you how to run a pretest loop.
- do-while – understand the posttest loop and learn when to use it in the script.
- break – learn how to break out of a loop.
- continue – show you how to skip the current loop iteration and start the new one from the beginning.
Section 6. Functions
- Functions – a quick introduction to the functions
- Function parameters – learn about function parameters, passing arguments by value, and passing arguments by reference.
- Default parameters – show you how to set a default value for a parameter.
- Named arguments – explain to you the named arguments that allow you to pass arguments to a function using the parameter names rather than parameter positions.
- Variable scopes – learn about the variable scopes, including global, local, static, and function parameters.
Section 7. Array
- Arrays – show you how to handle a list of items effectively with Array data type.
- Associative Arrays – learn how to use the associative arrays to reference elements by names rather than numbers.
- foreach – show you how to use the foreach statement to iterate over elements of an index array or an associative array.
- Multidimensional Array – guide you on how to define a multidimensional array and manipulate its elements effectively.
- array_unshift() – add one or more elements to the beginning of an array.
- array_push() – add one or more elements to the end of an array.
- array_pop() – remove an element from the end of an array and return it.
- array_shift() – remove an element from the beginning of an array and return it.
- array_keys() – get the keys of an array.
- array_key_exists() – check if a key exists in an array.
- in_array() – check if a value exists in an array.
- array_reverse() – reverse the order of elements in an array.
- array_merge() – merge multiple arrays into one.
Section 10. Encapsulation
- Objects – learn the basic concepts of OOP including objects and classes.
- The $this keyword – help you understand PHP
$thiskeyword and how to use it effectively.
- Access Modifiers: public vs. private – explain to you the access modifiers in PHP and help you understand the differences between the
- Constructor – explain to you the constructor concept and how to use it to initialize attributes.
- Magic Methods – learn how the magic methods work in PHP.
- Cloning Object – show you how to copy an object.
- Comparing Objects – learn how to compare two objects.
Section 11. Inheritance
- Inheritance – learn how to extends a class for code reuse.
- Call the parent constructor – show you how to call the parent constructor from a child class’s constructor.
- Overriding method – guide you on how to override a parent class’s method in the child class.
- Protected Access Modifier – explain the protected access modifier and how to use protected properties and methods effectively.
Section 12. Polymorphism
- Abstract Class – guide you on abstract classes and how to use them effectively.
- Interface – explain to you the interface concept and how to create interfaces.
- Polymorphism – explain the polymorphism concept and show you how to implement polymorphism in PHP using abstract classes or interfaces.
- Traits – introduce you to traits.
Section 13. Static methods & properties
Section 14. Exception Handling
- try…catch – show you how to use the try…catch statement to handle exceptions that may occur in your script.
- try…catch…finally – learn how to clean up the resources when an error occurs using the finally block.
- Throw an exception – guide you on how to throw an exception using the throw statement.
- Set an Exception Handler – show you how to use the set_exception_handler function to set a global exception handler to catch the uncaught exceptions.
Section 16. Advanced Array Operations
Section 17. Processing Forms
- PHP form – show you how to process HTML forms.
- filter_has_var() function – check if a variable of a type exists.
- filter_var() function – sanitize and validate a variable using a filter.
- filter_input() function – sanitize and validate a variable of a type.
- Form validation – walk you through the step of validating a form in PHP.
- Checkbox – learn how to process checkboxes.
- Radio button – learn how to handle radio buttons and radio groups.
- Select – show you how to handle the select element.
- File Upload– guide you on how to upload a file to the server.
Section 18. Working with Files
- Open a file – learn how to open a file for reading and/or writing using the
- Check a File Exists – show you how to check if a file exists using the file_exists(), is_readable(), and is_writable() functions.
- Read a file into a string – guide you on using the
file_get_contents()function to read a file into a string.
- Read a file into an array – show you how to read the contents of a file into an array, each line of the file is an array element.
- Download a file – show you how to download a file from the webserver.
- Copy a file – show you how to copy a file to a new one.
- Delete a file – learn how to delete a file.
- Rename a file – guide you on renaming a file to a new one and optionally move it to another directory.
- Work with CSV Files – learn how to create and read CSV files in PHP.
- Get the size of a file – show how to get the size of a file in bytes using the filesize() function.
- File permissions – learn about the file permission and how to change it using the
Section 19. Working with Directories
Section 20. String operations
- strlen – return the length of a string in bytes.
- substr – search for a substring in a string.
- strpos– locate the first occurrence of a substring in a string.
- str_replace– replace all occurrences of a substring with a new one in a string.
- implode – join an array of strings into a string using a separator.
- explode – split a string by a separator into an array of strings.
- trim – remove the whitespace characters or other characters from both ends of a string.
- ltrim – remove the whitespace characters or other characters from the beginning of a string.
- rtrim – remove the whitespace characters or other characters from the end of a string.
- htmlspecialchars() – show you how to escape special characters in a string.
- str_contains() – return true if a string contains with a substring.
- str_starts_with() – return true if a string starts with a substring.
- str_ends_with() – return true if a string ends with a substring.
- strtolower() – accept a string and return a new string with all alphabetic characters converted to lowercase.
- strtoupper() – accept a string and return a new string with all alphabetic characters converted to uppercase.
- ucfirst() – return a new string with the first alphabetic character converted to uppercase.
- ucwords() – return a new string with the first alphabetic character of each word converted to uppercase.
Section 21. Working with database
- Introduction to PHP Data Objects (PDO) – provide you with a quick overview of PHP Data Object, which is a standard interface for interacting with databases.
- Connect to MySQL – show you how to connect to the MySQL database server.
- Connect to PostgreSQL – learn how to connect to the PostgreSQL database server.
- Create a sample database – show you how to create a sample database in MySQL and a reusable script for connecting the database.
- Create a new table – guide you on how to create a new table in the database using PHP PDO.
- Insert data into a table – show you how to use a prepared statement to insert data into a table.
- Update data in a table – learn how to update data in a table from PHP using PDO prepared statements.