Category: PHP
-
PHP Exception Handling
What is an Exception An exception is a signal that indicates some sort of exceptional event or error has occurred. Exceptions can be caused due to various reasons, for example, database connection or query fails, file that you’re trying to access doesn’t exist, and so on. PHP provides a powerful exception handling mechanism that allows…
-
PHP Regular Expressions
What is Regular Expression Regular Expressions, commonly known as “regex” or “RegExp“, are a specially formatted text strings used to find patterns in text. Regular expressions are one of the most powerful tools available today for effective and efficient text processing and manipulations. For example, it can be used to verify whether the format of…
-
PHP JSON Parsing
What is JSON JSON stands for JavaScript Object Notation. JSON is a standard lightweight data-interchange format which is quick and easy to parse and generate. JSON, like XML, is a text-based format that’s easy to write and easy to understand for both humans and computers, but unlike XML, JSON data structures occupy less bandwidth than their XML versions.…
-
PHP Magic Constants
What is Magic Constants In the PHP constants chapter we’ve learned how to define and use constants in PHP script. PHP moreover also provide a set of special predefined constants that change depending on where they are used. These constants are called magic constants. For example, the value of __LINE__ depends on the line that it’s used on in…
-
PHP Classes and Objects
What is Object Oriented Programming Object-Oriented Programming (OOP) is a programming model that is based on the concept of classes and objects. As opposed to procedural programming where the focus is on writing procedures or functions that perform operations on the data, in object-oriented programming the focus is on the creations of objects which contain…
-
PHP Error Handling
Handling Errors Sometimes your application will not run as it supposed to do, resulting in an error. There are a number of reasons that may cause errors, for example: These types of errors are known as runtime errors, because they occur at the time the script runs. They are distinct from syntax errors that need…
-
PHP Filters
Validating and Sanitizing Data with Filters Sanitizing and validating user input is one of the most common tasks in a web application. To make this task easier PHP provides native filter extension that you can use to sanitize or validate data such as e-mail addresses, URLs, IP addresses, etc. To validate data using filter extension…
-
PHP Form Validation
Sanitizing and Validating Form Data As you have seen in the previous tutorial, the process of capturing and displaying the submitted form data is quite simple. In this tutorial you will learn how to implement a simple contact form on your website that allows the user to send their comment and feedback through email. We…
-
PHP Form Handling
Creating a Simple Contact Form In this tutorial we are going to create a simple HMTL contact form that allows users to enter their comment and feedback then displays it to the browser using PHP. Open up your favorite code editor and create a new PHP file. Now type the following code and save this…
-
PHP Send Emails
The PHP mail() Function Sending email messages are very common for a web application, for example, sending welcome email when a user create an account on your website, sending newsletters to your registered users, or getting user feedback or comment through website’s contact form, and so on. You can use the PHP built-in mail() function for creating and sending…