Category: PHP

  • Session Options

    From PHP version 7 onwards, the session_start() function accepts an array of options to override the session configuration directives set in “php.ini”. The [session] session in “php.ini” defines the default values of various options. The options, if provided, are in the form of an associative array of options that will override the currently set session configuration directives.…

  • Sessions

    A web session is the time duration between the time a user establishes connection with a server and the time the connection is terminated. Along with the cookies, the session variables make the data accessible across the various pages of an entire website. During a session, the website maintains information about the user’s actions and…

  • Cookies

    The worldwide web is powered by HTTP protocol, which is a stateless protocol. The mechanism of Cookies helps the server maintain the information of previous requests. PHP transparently supports HTTP cookies. Understanding Cookies in PHP This chapter will teach you how to set cookies, how to access them and how to delete them. The Anatomy…

  • File Uploading

    One of the common features required in a typical PHP web application is the provision of letting the user upload files. Uploading files from a client is very easy in PHP. In this chapter, we shall learn how to use PHP script for the file upload process. How to Upload a File? The process of…

  • GET & POST

    Since PHP is mostly used for web application development, the data sent by the browser client is mainly with the GET and POST types of HTTP request methods. The HTTP protocol also defines other methods for sending the request to the server. They are PUT, DELETE, HEAD and OPTIONS (in addition to GET and POST…

  • File Inclusion

    When developing websites, we generally have to reuse the same information or code in many places. For example, we might want the same header, footer or menu across all pages. PHP allows us to use file inclusion instead of writing the same code many times! File inclusion saves time, organizes our code and allows us…

  • Compound Types

    Data types in PHP can be of “scalar type” or “compound type”. Integer, float, Boolean and string types are scalar types, whereas array and object types are classified as compound types. Values of more than one types can be stored together in a single variable of a compound type. In PHP, objects and arrays are…

  • Heredoc & Nowdoc

    Heredoc and Nowdoc are PHP methods that allow you to write long strings without using too many quotes or escape characters. They allow you to write multi-line strings in a neat and readable manner. PHP provides two alternatives for declaring single or double quoted strings in the form of heredoc and newdoc syntax. Heredoc is useful for including variables,…

  • Maths Functions

    Mathematical operations are important parts of programming. PHP has several built-in math functions that make calculations easy. These functions can be used to round numbers, find maximum and minimum values, work with exponents and logarithms and so on. In this chapter, we will look at different PHP math functions and mathematical (arithmetic) operators and how…

  • Files & I/O

    PHP Files and I/O is the process of reading, writing, creating and deleting files. PHP has various functions for easy file management. We can open a file and write to or read from it. Functions like fopen(), fread() and fwrite() are very useful. Files allow you to store data for later use. Getting data from…