
Prepare your php development toolkit by installing Notepad++ and setting up Wamp server, then create, save, and test php files in the 3w folder using localhost.
Explore the anatomy of a typical php file, including start and end tags, php statements, the required semicolon, and comments with //, #, or /* */.
Computer is invented to process data.
To better handle data, data has been divided into several types.
As a programmer, whenever you see the word data, ask two questions: data type and data value.
PHP has offered us a basket to store values. The basket is called variable.
You will learn how to create a variable and how to assign value to it.
when it comes to handling variable, single quotes and double quotes behave differently.
A new data type: NULL.
Assigning NULL to a variable can empty that variable.
you might think value assignment between variables are simple, but there might be things you not know.
Pass value by reference.
The ampersand can tie two variables to one value.
this is the end of the yellow belt, before you move on, you might want to slow things down a little bit and do a review of what you have learnt so far.
A review of what you have learnt in the Yellow Belt Lessons. and also hope you like the music.
A review of what you have learnt in the Yellow Belt Lessons.
The building stone of PHP is expression.
The tool we can use to process data: operator.
Practice uses assignment, string, arithmetic, and comparison operators through variable creation, string concatenation, numeric calculations, and precedence testing to reinforce PHP operator syntax and outcomes.
Give your program a steering wheel so that it can make decisions.
The IF statement.
How to use it and how it works.
Sometimes the program needs to make decisions based on variable values.
In this case, IF statement is not convenient.
SWITCH statement.
What kind of value will be regarded as FALSE.
Ternary operator.
WHILE statement.
How to let the program do repetitions.
Show how a while loop echoes a message while condition is true and increments counter to ten. Initialize a variable to 1, test var <= 10, then echo and increment.
There is another form of WHILE statement: do while.
Another form of LOOP statement: FOR statement
Explore how pre and post increment work in PHP, compare auto increment nuances, and apply plus-equals and string concatenation to manipulate variables and strings in dynamic websites.
The reason why making web apps using PHP is fast and convenient is because of all the brilliant built-in functions PHP has.
But as new learners, there might be some tricky parts about functions.
Always remember the key in using a function is that you have given each function argument a correct value and most importantly, you have put those values in the correct order.
sometimes, you just have to create your own functions, this lesson will teach you how to do that and how to do that properly.
normally, the value returned by a function is NULL. but sometimes, you need control the returned value because the following operations will depend on that.
the keyword RETURN also means the end. Codes behind it will not be executed. In the future, you will find that RETURN is a brilliant tool and you will use it a lot.
changing variable value is simple, but if you want to do that using a function, things are a little bit more complicated.
inside and outside a function, there are two different worlds. Using the keyword GLOBAL, you can break that wall.
you can set default values to function arguments. But if you want to do that properly, there are some rules you must follow.
Create constants in PHP with define, learn naming rules, and that a constant's value cannot be changed, with default case sensitivity and optional true to make it case insensitive.
Compared with variable, array is much more powerful, In the future, you will probably use more arrays than variables.
array is powerful, but to use it, you must use a tool: the foreach loop statement
Explore how foreach splits arrays, including multi-dimensional arrays, and why echoing an array fails. Build a recursive function to echo all values, using the array function to test for arrays.
Learn essential php array functions, including count, is_array, in_array, array_combine, array_merge, array_shift, and array_pop, and understand loose versus strict comparisons and default values.
callback can be very helpful sometimes, but its concept is a little tricky to understand.
Explore how PHP's array_walk applies a user supplied function to every array element, using value as first argument, key as second, and an optional third value, with by-reference updates.
there is no way you can put all your codes in one file. but if you write your codes in different files, how do you allow those files to exchange information with each other???
to achieve cross-file communication, you must be able to locate each file.
you will be using array almost all the time in the future. This means you will constantly do all kinds of manipulations to arrays.
converting array into a string is the fist conversion technique you need to learn.
sometimes, you might need to convert a string into an array, so how to do that?
there is another way to convert a string into an array.
Build a PHP file type detector by exploding the file name and using array_pop to get the last element as the extension.
if you need a part of a string, how do you get that???
Use the string replace function to swap zeros with the word zero in a string, using four arguments (last optional) and track replacements with a counter.
Learn to verify email addresses using preg_match with regular expressions, and master pattern design basics, anchors, character classes, quantifiers, and escaping.
you will learn something that will make you feel quite powerful: how to use PHP commands to create files.
how to open a file and how to close a file.
if you want to know the content of a file, how do you get that?
if you want to put new contents into a file, how do you do that?
here are four functions you are recommended to learn by yourself. I will teach you how to use those four functions in the next lesson, but for now, try to learn them all by yourself.
Use file exist to check if a file or directory exists. Use file to test a regular file, file size to get the file size, and unlink to delete.
this bluebelt demonstration creates file.txt, writes 1 through 0, and uses file_exists, filesize, and unlink to verify existence, measure size, and delete the file.
Learn how feof() tests the end of a file in PHP, and how separate read and write pointers track progress for safe handling of large files.
how do you read a large file efficiently?
how to copy, relocate and rename a file
Track web page visits by storing a counter in a text file, updating on each visit, handling the first visit when the file doesn't exist, then reading and incrementing.
to manage files, you need to have file folders or directories. so how to create them?
Open, read, and close a directory to reveal its contents, learning that each read returns a name, not the path, and that dot and dot-dot denote root and parent folders.
BlueBelt shows how to delete directories and files together using a recursive super delete function that traverses a directory, unlinks files, and removes the nation directory once empty.
although you are a back-end programmer, there are certain front-end techs you just have to know
Discover how to send data with form and input tags using action and method, choose post for passwords and get for others, and read submitted data from the global array.
Learn how to send and receive form data with an HTML form and process.php using post, with username and password inputs, and $_POST in PHP to echo values.
Use the get method to send data with a hyperlink by placing a question mark, then the username and password, with ampersands separating values to the destination process.
Learn to upload a file with a PHP form, using an input named upload, configure max file size, inspect $_FILES for size and tmp_name, then move_uploaded_file to destination.
Upload a photo to a destination folder using a PHP form with a 30 megabyte limit, validate the submit, and move the uploaded file with move_uploaded_file; confirm success.
Learn to secure file uploads by implementing security checks, organizing storage, and renaming files properly to mitigate risks when users upload to your server.
Learn to validate uploaded file types in PHP by using the switch statement on the global upload array, accepting image/jpeg and exiting on illegal types.
Rename uploaded files using time and rand, extract extensions with explode and array_pop, and create year and month directories with mkdir for successful uploads.
Explains how to download a file by using the head function to tell the browser to download, specify the file size and name, and read contents with a while loop.
Display six pictures, convert each into a get method download link, send the picture name via a global array, build its url, and trigger the browser to download.
Identify and fix download program weakness by validating the file path against a whitelist of downloadable files, using safe get data and implementing checks to prevent unauthorized downloads.
Learn why object-oriented programming should come before MySQL in PHP development to store file ownership and retrieval in a database; MySQL is powerful, popular, and free.
learn object oriented programming by understanding objects as data types and how to declare them; compare procedural programming and see how OOP lets you write less and reuse more.
Refactor a file upload program into object oriented modules and classes, covering error and type control and file handling. Learn the one class one independent file rule and naming conventions.
This lecture shows how to create a PHP class, declare properties and methods, set a default value, instantiate the class with require and new, and call methods with arguments.
Explore the MySQL database and the MySQLi class in PHP, understanding databases as warehouses with tables, columns, and rows, and learn to navigate their structure and core concepts.
Learn to operate and manage databases with phpMyAdmin, create databases and tables, set collation to UTF-8 for multilingual sites, and navigate the WAMP-based interface to view table structures.
Explore the 30 MySQL data types across date and time, numeric, and string categories, and learn how storage size, fixed versus variable length, and length attributes affect database design.
Create a new database and a table, set the primary key field with autoincrement, and define engine and transmission fields with appropriate types and lengths, plus storage options and collation.
Demonstrates connecting to a MySQL database in PHP using the construct method (localhost, root, car) and the connect method, checking success, suppressing errors with @, and disconnecting with close.
Learn to retrieve data with SQL select statements, use back quotes for identifiers and capitalization for readability, then execute the query and fetch results with fetch array or fetch row.
Demonstrate retrieving six rows from car info table by connecting to the database, preparing and executing a select query, fetching results with fetch array in a loop, and freeing resources.
Learn to organize retrieved data using SQL limits and conditions, selecting specific rows with start index 0, where clauses, and like patterns with a percent wildcard.
Learn how to update and delete rows in a MySQL database with PHP, using where and limit 1 to protect data, and how the query method returns true or false.
Learn to validate and filter user input with regular expressions, controlling content and length, and escape all special characters before database insertion to prevent sql injection.
Master four database operations and connect using the connect or construct method, handle errors, and use the query method for retrieval, insert, update, or delete with where and limit safeguards.
build a login program that uses post, validates inputs, connects to a MySQL database, encrypts and compares passwords, and authenticates users before granting access.
Learn how to complete a PHP membership system by creating a private home page, redirecting with window.location, and solving login-required access and username display from the database.
Explore how a university balances access control by using ID cards for general entry and fingerprint scanners for sensitive areas, combining cost and safety for robust security.
Explain cookies and sessions as web identity tools: cookies stay on the browser, sessions live on the server, with admins using sessions and ordinary users relying on cookies.
Set two cookies, user id and security, after login and place a cookie scanner on every page to verify the token against an encrypted md5 value retrieved from the database.
Create an id card and a card scanner, implement cookie-based authentication for user id and security, validate the user against the database, and verify the md5 password to grant access.
Learn to securely log out by revoking the id card, expiring cookies with setcookie to time() minus one, and ensuring the correct path, after verifying login state before logout.
Add a new function to the membership system, implement a file upload flow, and verify successful uploads including file types, folders, and automatic renaming within the index workflow.
Create a picture table to store file names and link each image to a user via user_id. Use insert_id to get the primary key after inserting into the parent table.
Identify a cookie tampering vulnerability in image uploads and demonstrate fixing it by rechecking user identity before every operation and securing the upload process with a scanner.
Prevent duplicate image uploads by using a switch cookie during the upload process. If the switch is on, delete it and proceed; otherwise deny the upload.
learn to start a php session with session_start, avoid any output before it, and identify users via the session id stored in the php sess id cookie.
Start a session and store a value in the global session array under a password key, such as one two three four five six a b c.
Learn how to create a blank canvas with image create true color, specify width and height, handle the returned resource, and note GIF is not supported.
Create a paint brush on a blank canvas using image fill, set a background color, and apply red ink at 0,0 to return true.
Output an image in PHP by using the image function with imagejpeg or imagepng, set the Content-Type header, optionally store the image in a database, and destroy the resource.
assemble the lessons to create a verification code image: build a canvas, allocate colors, add a border, sprinkle random pixels, and render four random characters.
Watermark a picture using a logo or a text string, convert destination image into a canvas with image create from, and obtain width and height with imagesx and imagesy.
Overlay a logo as a watermark on a destination picture by converting the logo to a bitmap and using image copy with x, y, width, height to position it.
Learn to crop a picture with the image copy function by creating canvases, selecting a left top quarter using x, y, width and height, and pasting onto a new canvas.
Scale down a picture to a thumbnail using image copy resized or image copy sampled, then create a new canvas with the original’s width and height and fill it white.
The aim of this course is to help you master web development in the most efficient way.
The content design of this course is inspired by the Jiu Jitsu ranking system.
The whole course includes seven levels: yellow, orange, green, blue, purple, brown and black.
In yellow, orange and green course, considering you just started your PHP study, the learning curve is kept at a rather smooth level.
You will learn the most fundamental coding concepts and simple operations.
In blue belt, things start to change. The learning curve starts to get steep and you will need to combine skills learnt at different times together.
After purple belt, you will start to build programs that can be used in real-life situation. This means you will need to take into consideration safety and efficiency.
We know that everybody forgets. We also know that you have other things going on with your life and your study will be constantly interrupted. Therefore, every time previous knowledge is needed, we will give you a timely review. We believe this can make your study easier and more efficient.
Starting from purple belt, you will learn how to build program that can survive in real life. This means you need to learn more than just coding skills. You will learn program design and safety and efficiency knowledge.