Author: Saim Khalid

  • 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…

  • Integers

    Integers in PHP Integer is one of the built-in scalar types in PHP. A whole number, without a decimal point in the literal, is of the type “int” in PHP. An integer can be represented in decimal (base 10), hexadecimal (base 16), octal (base 8) or binary (base 2) notation. To use octal notation, a…

  • Boolean

    Boolean Type in PHP In PHP, “bool” is a basic data type. It informs if something is true or not. A Boolean can only have two values: true or false. True and false in PHP can be written in several ways, such as true, TRUE, or True, and they all mean the same thing. Boolean…

  • Strings

    A string is a sequence of characters, like ‘PHP supports string operations.’ A string in PHP as an array of bytes and an integer indicating the length of the buffer. In PHP, a character is the same as a byte. This means that PHP only supports a 256-character set, and hence does not offer native…

  • Type Juggling

    PHP is a dynamically typed language, which means the type of a variable can be changed based on the value sent to it at runtime. This automatic type conversion in PHP is called type juggling. In languages like C, C++ and Java, a variable’s type must be defined before it can be used and it…

  • Type Casting

    The term “Type Casting” refers to conversion of one type of data to another. Since PHP is a weakly typed language, the parser coerces certain data types into others while performing certain operations. For example, a string having digits is converted to integer if it is one of the operands involved in the addition operation.…

  • Data Types

    The term “Data Types” refers to the classification of data in distinct categories in PHP. Data types define the types of data that a variable can store. PHP supports a wide range of data types, like string, integer, float etc. Data types make it easier to store and handle information in programs. Knowing data types…

  • Magic Constants

    The magical constants in PHP are predefined constants. They are available to any script on which they run, and they change depending on where they are used. All these “magical” constants are resolved at compile time, unlike regular constants, which are resolved at runtime. There are nine magical constants in PHP. These special constants are…