*** Learn the modern way of writing PHP *** with 30 interactive exercises ***
Are you looking for an interactive, step-by-step program to master modern PHP and kickstart your career as a web developer in 2024? Then read on.
Many say that PHP is dead. But the truth is, PHP still powers 75% of online web applications today. This means that if you’re looking to get a job as a web developer, or start a lucrative freelance career, you will encounter PHP.
The problem is, many courses focus on an old way of writing PHP, which is becoming outdated in the market. Following these programs will just make you frustrated because the code won’t scale and will be difficult to maintain. You won’t learn the required practices needed to build big-scale web applications, and therefore will never be able to kickstart a fulfilling career as a PHP developer.
This program aims to change that.
I designed this course to help you master PHP, step by step from beginner to pro, but in a way how it’s written nowadays. We’ll focus on mastering the concepts that can get you from 0 to building a simple content management system (CMS) with your own framework.
We will start with simple PHP code, but step by step, we’ll introduce additional, concepts that turn PHP into a modern, powerful language: Object oriented programming, namespaces, autoloading, PSR-4, inheritance, PDO, MVC framework – just to name a few.
Also, you will learn about best-practices that help you prevent security attacks. You will learn how to prevent cross-site-scripting (XSS) attacks, SQL injections, privilege escalation attacks and even more. Being aware and being able to mitigate those risks is essential if you want to become a sought-after freelancer or an in-demand senior developer that companies can rely on.
And mind you, this course isn’t just be theoretical. The chapters are packed with practical examples, engaging quizzes, and real-world scenarios that will make this experience fun and engaging. Plus, at the end of the course, you will also have built several projects you can showcase and use in your portfolio!
Last but not least, you will also learn the ‘why’ behind PHP – so that you feel confident to go out there and apply this knowledge to real-life projects.
So, after this course you will also be able to master various development styles. This course covers it all:
From simple PHP scripts for smaller projects
Over object oriented scripts for medium-sized projects
Up to MVC-Frameworks for large-scale projects
This allows you to develop professionally and know when you should use which style.
Some things you will learn:
PHP basics
How to run file uploads
How a web server works
How to access a database and write a guestbook
How to embed PHP in HTML
Functions, arrays, strings, if conditions,…
Control a database (MySQL / phpmyadmin)
How to create simple websites with PHP scripts
How to create an image gallery with upload functionality
How to write a CMS with object orientation & MVC patterns
Cookies & Sessions: Create a login system (and a cookie notice)
Learn how to keep track of complex projects with advanced PHP features (namespaces, autoloading, PSR-4, MVC patterns, container patterns, inheritance, …)
The german version of this course is already the most popular PHP course on the German market here on Udemy. With this enhanced, english version, I’m opening this knowledge to the international market.
Enroll now and get your foot in the exciting world of web development!
In this lesson, you create your first PHP file and learn how PHP integrates with HTML, making every HTML code also a PHP code.
You explore how PHP blocks (marked with <?php and ?>) within an HTML file can run PHP commands, to generate dynamic outputs on your webpages, such as displaying random numbers.
Additionally, you come to understand the precise nature of PHP and how even minor mistakes in your PHP code can cause your entire program to fail.
In this lesson, you gain a practical understanding of how PHP generates HTML, enabling you to witness firsthand how browsers interpret and display this code.
You learn the intricacies of PHP's ability to create any text, including HTML, and how this influences the way web browsers present the resulting content.
Moreover, the lesson guides you through using PHP in combination with CSS to dynamically design and modify web pages.
In this lesson, you explore dividing your PHP code into several files which can help simplify the deployment of HTML websites and create shared HTML structures.
You learn about the 'include' command in PHP, which allows you to import and execute code from other files.
You understand that even non-PHP files (such as .txt files) can be included and executed as PHP code, although it’s best practice to use .php extensions.
In this lesson, you learn about variables in PHP and how they can be used to store and manipulate data.
You see how to create variables using the dollar sign ($), set their values with the equals sign (=), and output their values using the echo statement.
You also learn how variables can be useful for dynamic web page creation, allowing you to easily change content in multiple places by modifying a single variable.
Through this lecture, you're introduced to the project of developing a restaurant website using PHP to transform a single-page site into a multi-page one.
You learn basic HTML and CSS coding, including the use of tags, creating a navigation bar, and the insertion of images and text.
The lecture also touches on the limitations of HTML when it comes to adding new pages, setting the stage for utilizing PHP to simplify this process.
In this lecture, you learn how to facilitate website navigation by adopting PHP instead of HTML.
You understand how to rename .html to .php, create a new folder for 'includes', and initiate an include command.
Finally, you grasp how PHP codes can enable easy changes across all website pages, offering a solution to repetitive manual changes in navigation.
In this lecture, you learn how to optimize a website using PHP to alter the background image and title based on the webpage you're on.
You discover how to define variables before including headers, allowing these variables to be output in different files.
You're also taught how to manage errors, ensuring that PHP configurations complain when variables aren't existing.
The lecture ends with an exercise, encouraging you to add a new page on your own by integrating the learnt PHP process.
In this sample solution, you learn about how to transform HTML pages into PHP to allow the execution of PHP code.
You are shown how to change the file extensions of HTML to .php, enabling you to incorporate these files into your navigation.
The process of copying structures from other pages, inserting new configurations, and including page elements like headers and footers is demonstrated, reinforcing how PHP can simplify website extension and management.
In this lecture, you learn about potential problems that can occur in PHP due to syntax errors.
This includes parse errors that occur when PHP cannot understand the structure of a code, causing it to fail in execution.
You are also taught about warnings, which flag up problems but do not halt program execution, as well as fatal errors which indicate serious problems resulting in program termination.
In this PHP tutorial, you learn about strings and how they work.
You understand that strings are collections of characters and can be manipulated with a concatenation operator.
The lecture also teaches you about string handling, including escape sequences for problematic characters.
In this lecture, you learn about defining strings in PHP using double quotes.
Double quotes allow you to include single quotes within the string without escaping and enable certain operations that aren't supported in single quoted strings, like accessing variables inside the string.
However, you should use single quotes when possible to avoid unwanted behaviours and only use double quotes when necessary.
In this PHP lecture, you learn how to work with numbers and perform calculations without the need for quotes.
You understand how variables can be used for calculations, how PHP tries to automatically convert types, and the associated potential errors if non-numeric strings are used in calculations.
Lastly, you learn that PHP seamlessly works with floats (decimal numbers), offering ease in performing diverse mathematical operations.
The lecture covers the importance and uses of the vardump function in PHP.
You learn how to invoke the vardump function to give better insight during debugging than an echo would.
The function allows you to ascertain the type and details of variables, how special characters and non-English characters may need additional space, and how the function works with numbers, string conversions, and variables.
In this lecture, you learn about the fundamental concept of booleans in PHP, which represent either a true or false value.
You discover how booleans are created through various comparisons, such as larger than, smaller than, equals, and not equals, with and without type checking.
Furthermore, you understand the importance of using strict comparisons to ensure type and value equality, which helps to avoid potential programming problems.
In this lecture, you learn about the 'if-construct' while programming PHP which determines if a certain block of code executes.
You are taught how to use simple booleans or create an evaluation expression to control the executed code.
You also learn how to include multiple lines of code in one block and the usage of curly brackets when writing the if-construct.
The lecture educates you on the use of 'if', 'else', and 'else if' statements to create conditions in PHP that manipulate server output based on server status.
You also learn the importance of ordering these clauses appropriately for accurate evaluation of conditions, cautioning you against interrupting the 'if' and 'else' blocks.
Furthermore, it illustrates ways to test the same variable for different values to increase your code's efficiency and flexibility.
In this lecture, you learn about the functions isset and empty in PHP which are used to query the status of a variable.
You find out that isset checks if a variable exists, returning true if it does, and false if it doesn't while empty also checks if the variable exists and whether it contains a value, considering a variable empty if it doesn't exist or contains a zero.
Additionally, it's taught that you can use unset to completely remove a variable.
This lecture focuses on PHP alternative syntax, mainly used for embedding PHP into HTML code.
You're taught how to transform the classic syntax into the cleaner alternative syntax for conditional statements, making HTML structure evident, and helping differentiate between different uses of curly braces within PHP.
It's suggested that alternative syntax is ideal for generating HTML and standard syntax for implementing logic.
In this lecture, you're learning about working with Boolean operators in PHP.
You're taught how to flip Booleans, logical AND, OR, and XOR.
The lecture emphasizes that these operators are usually used within conditions in if statements, and highlights how to create expressions that evaluate to a Boolean.
It provides greater flexibility for writing if statements and is central to combining Booleans and expressions.
In this lecture, you're asked to improve your restaurant project by adding functionalities to the navigation bar that shows which page is active, provide a default background image for pages that do not specify one, and create a default title for pages that do not provide one.
The alternative PHP syntax is highlighted as it can be used to toggle certain attributes within an HTML tag.
This Sample Solution introduces ways to troubleshoot and refactor your code to mitigate errors and enhance web page flexibility.
You learn tactics such as removing variables, mitigating warnings, and ensuring all your content still appears through the use of default settings.
This section of the sample solution demonstrates how to highlight the active menu item on your website by toggling a CSS class named active.
It demonstrates how to use a PHP code to highlight the site that you currently want.
It also shows how to use a variable called pageKey to identify which page you are on and apply the active class to it.
In this lecture, you learn about arrays in PHP, which allow you to group multiple values together in one variable.
Arrays help you avoid inconsistencies on your website by enabling you to generate list elements on the fly, so they are no longer fixed.
Furthermore, adding a new element to your arrays automatically updates all parts of your site referring to that array, providing a consistent user experience.
In this lecture, you learn to solve the issue of defining multiple categories on a website using PHP's array function.
You understand how to declare an array, adding items and defining elements within it using echo or var_dump functions.
You also explore how to access individual elements from the array and how to turn these elements into variables.
The lecture also covers the flexibility of arrays in PHP, explaining they can hold any value and offering two ways to declare an array; using either array() or square brackets [].
In this lecture, you learn more about working with arrays in PHP, including how to access, test the existence of elements, and how to handle non-existent elements.
You learn to use 'isset' or 'empty' to test if an element exists, and 'in_array' to check for specific values.
Additionally, you understand how to use 'count' to get the number of elements in an array.
In this lecture, you learn how to modify PHP arrays including how to change, delete, and add elements.
You discover that using 'unset' on an array removes an entry entirely, but does not shift subsequent keys up, leaving the possibility of missing elements.
Lastly, you learn that using consecutive keys when appending elements simplifies your code and makes arrays easier to work with.
This lecture teaches you how to use PHP to run a giveaway by writing code to randomly select a name from a list of subscribers.
You see how to define arrays, use best practices when adding entries, utilize count and rand functions to select a winner, and output this information via var_dump or echo.
In this lecture, you learn about working with arrays in PHP using array functions.
You're taught how to remove duplicates from an array using the 'array_unique' function and how to sort arrays alphabetically with the 'sort' function.
The lecture introduces a variety of other PHP array functions available that you can explore further on php.net or via your code editor's autocomplete feature.
In this lecture, you learn about the for-each loop, a tool in PHP that enables you to repeatedly run a block of code for each element in an array.
Specifically, you delve into its syntax, how to use it to generate HTML code, and its alternative syntax ideal for HTML.
Last but not least, you're given tips on variable naming and handling whitespaces to enhance code readability and design respectively.
In this lecture, you learn about the 'break' and 'continue' keywords to control iterations of for each loop in PHP.
'Continue' allows you to skip an iteration and move on to the next one if the condition is true.
In contrast, 'break' not only ends the current iteration but terminates the whole loop.
Both these keywords work in the PHP alternative syntax, offering efficient control over the loop's execution.
In this lecture, you learn about associative arrays in PHP.
Associative arrays allow you to store key-value pairs in one array, offering an efficient way to access and manage related data.
You also discover how to check if a certain key exists and if its value is not empty.
In this lecture, you're introduced to the manipulation and usage of associative arrays in PHP.
Specifically, you're shown how to add, override, and remove entries, use count to determine the number of elements, and navigate the array using foreach.
Furthermore, you'll learn how to use two useful PHP array functions, array_keys and array_values, to extract the keys and values out of your associative array for further manipulation.
In this lecture, you learn how to manage associative arrays in PHP.
You explore what happens when a new entry is added without specifying a key, with PHP automatically generating a numeric key for you.
The lecture advises against mixing associative arrays with normal arrays, even though it is technically possible, as this can lead to confusion in the code and potential problems later on.
In this lecture, you learn how to add parameters to a URL in a PHP file, an essential skill for creating interactive web pages.
You are taught how to use the $_GET array in PHP to access these parameters and manipulate them within the script, which can include checking if a parameter is empty and printing a parameter's value.
The lecture teaches you how to automatically create a URL link with parameters using PHP.
It explains how to create a hyperlink to a current page and add parameters such as the name of a book.
You also learn to use the HTTP build query function to convert an array into a query string, avoiding potential browser issues or different interpretations.
In this lecture, you learn about integrating parameters into URLs through HTML form elements to interact with PHP scripts.
First, you create a form to submit parameters through GET, exploring ways to generate and submit information via the browser to the server.
Additionally, you examine how to auto-fill an input field following form submission to boost user experience.
In this lecture, you learn about form submission in PHP.
We discuss the limitations of using the GET method for form submission, most notably the security issue of sensitive data like passwords being visible in the URL, and the alternative: the POST method.
Lastly, you're reminded that data transferred through HTTP is unencrypted and warned about the potential for cross-site scripting attacks.
In this lecture, you learn the importance of securing your website against cross-site scripting (XSS) attacks, where malicious input can wrongly be interpreted as code.
Specifically, you learn the necessity of using PHP's `htmlspecialchars` function, which converts special characters to their HTML entities and prevent them from being wrongly interpreted as HTML tags.
Furthermore, you learn how to make this process easier by creating a handy custom function `e`, which does the necessary conversions for you every time you output content, even if it's not user-generated.
In this lecture, you undertake a project to create a recipe selection application, which will allow choosing a recipe from a dropdown.
You initially use PHP's 'include()' function to load the dynamic content, however, this presents a security flaw as it can execute arbitrary PHP code.
To avoid this, you transition to using 'file_get_contents()' function, which loads the contents of a .html file without executing any PHP code, thus enhancing security.
In this lecture, you learn about the importance of secure coding, especially when dealing with user-generated inputs.
We identify and fix a security flaw in our recipe app which allowed access to non-allowed files by checking whether the user's input matches an allowlist before loading the file.
Your task now is to refactor the code to make it more maintainable by converting it to an associative array, which will automate the option menu generation and consolidate all specifications into one array.
In this lecture, you learn how to enhance your code quality by using an associative array in PHP.
This process involves defining your array, looping through it using a 'foreach' loop and generating corresponding HTML options using 'echo' and the 'e' function.
Finally, you discover how to select specific elements from the array using the 'empty' function, ultimately improving the functionality and safety of your code.
In this lecture, you're tasked to create an image gallery using arrays and PHP to enhance flexibility.
You'll commence the project with an empty page and then implement a list of clickable images using the provided project materials.
Remember to consider things like the get parameter in your image.php file, using provided functions, and building the correct path to access your images.
The lecture covers the crucial role the rawurlencode function plays in ensuring filenames, even those with special characters or white spaces, are correctly and safely outputted.
You are also cautioned to only apply the function to filenames, not paths, to avoid compromising the URL's structure.
In this lecture, you learn how to manipulate the display of images with differing aspect ratios using CSS.
The lecture introduces 'object-fit', a property that adjusts how image content fits into an image element, and explains how to use 'aspect-ratio' within CSS to ensure images display at exactly the same dimensions regardless of their original aspect ratios.
Lastly, it suggests that these techniques can improve the design of your image gallery.
The lecture guides you on creating a gallery page in PHP, starting with displaying a series of images using an array, generating image tags, and outputting these on the webpage.
It explains how to handle errors by displaying alt text and how to adjust image paths.
It also adds functionality such as clickable images which then navigate to a new webpage.
In this lecture, you learn how to improve the design of an image gallery using CSS.
You understand how to make an element a block element to style it more easily, using CSS properties to manage the size and spacing of your gallery items.
You also discover how to use flexbox to display multiple elements side by side, manage white space, and align your elements
This ensures your gallery not only functions well but also looks visually appealing.
In this PHP tutorial, you learn how to implement an individual image page within a gallery.
The primary focus is on validating URL parameters against an allow list with image titles, safeguarding against potential cross-site scripting attacks.
Additionally, this lecture shows how to correctly sanitise and format image attributes for display and how to add navigation for a better user experience.