Category: PHP

  • Form Email/URL

    PHP provides two alternatives for validating the form data items which are strings but are expected to be a representation of Email ID or a URL. One way to check the form element contains email/URL is with the use of RegEx (regular expressions), and the other, more convenient approach is to use filter_var() function. Let us…

  • Form Validation

    The term “Form Validation” refers to the process of ascertaining if the data entered by the user in various form elements is acceptable for further processing. Validation of data before its subsequent processing avoids possible exceptions and runtime errors. Types of Form Validation Validation can be done both on the client-side and on the server-side.…

  • Form Handling

    HTML Forms play an important role in PHP web applications. Although a webpage composed purely with HTML is a static webpage, the HTML form component is an important feature that helps in bringing interactivity and rendering dynamic content. PHP’s form handling functionality can validate data collected from the user, before processing. What is Form Handling ?…

  • Web Concepts

    PHP is a server-side scripting language that is used to create dynamic webpages. It is one of the most popular programming languages for web development. This chapter aims to let you get familiarized with certain important concepts of web application development using PHP. A web-based application is a collection of webpages. A webpage is mainly…

  • Anonymous Classes

    The release of version 7.0 is an important milestone in the evolution of PHP language, when a lot of new features were introduced. The feature of Anonymous class was also made available in PHP version 7.0. As the term “anonymous” suggests, it is a class without a (programmer declared) name. The usual practice is to…

  • Cloning Objects

    A PHP statement such as “$obj1 = $obj2” merely creates another reference to the same object in memory. Hence, changes in attribute reflect both in original and duplicate object. The clone keyword in PHP creates a shallow copy of an object. $obj2=$obj1 Changes in the original object do not reflect in the shallow copy. Cloning Types There…

  • Overloading

    In C++ or Java, the term means a class can a class method of same name more than once but with different arguments and/or return type. In PHP, the term overloading has a different interpretation. It is a feature with which properties and methods can be created dynamically. PHP’s magic methods (method names starting with…

  • The Final Keyword

    In PHP, the final keyword prevents classes and functions from being changed or overridden. It helps to keep important parts of your code secure, to guarantee no one accidentally breaks them while making changes. The “final” keyword is used in the definition of a class, a method inside a class, as well as with the definition of…

  • Encapsulation

    PHP implements encapsulation, one of the important principles of OOP with access control keywords: public, private and protected. Encapsulation refers to the mechanism of keeping the data members or properties of an object away from the reach of the environment outside the class, allowing controlled access only through the methods or functions available in the class. Principle of Encapsulation…

  • Object Iteration

    When working with objects in PHP, you may want to go over each property one by one. This is referred to as object iteration. It is useful when you want to verify or display all of an object’s properties without having to access them individually. A foreach loop may be employed to iterate through all the publicly…