Author: admin

  • Heredoc & Nowdoc

    PHP provides two alternatives for declaring single or double quoted strings in the form of heredoc and newdoc syntax. Heredoc Strings in PHP The heredoc strings in PHP are much like double-quoted strings, without the double-quotes. It means that they don’t need to escape quotes and expand variables. Heredoc Syntax First, start with the “<<<” operator. After this operator,…

  • Maths Functions

    To enable mathematical operations, PHP has mathematical (arithmetic) operators and a number of mathematical functions. In this chapter, the following mathematical functions are explained with examples. PHP abs() Function The abs() function is an in-built function in PHP iterpreter. This function accepts any number as argument and returns a positive value, disregarding its sign. Absolute…

  • Files & I/O

    This chapter will explain following functions related to files − Opening and Closing Files The PHP fopen() function is used to open a file. It requires two arguments stating first the file name and then mode in which to operate. Files modes can be specified as one of the six options in this table. Sr.No Mode &…

  • Integers

    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 number is preceded…

  • Boolean

    In PHP, “bool” is one of the built-in scalar data types. It is used to express the truth value, and it can be either True or False. A Boolean literal uses the PHP constants True or False. These constants are case-insensitive, in the sense, true, TRUE or True are synonymous. You can declare a variable…

  • 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 known as a dynamically typed language. The type of a variable in PHP changes dynamically. This feature is called “type juggling” in PHP. In C, C++ and Java, you need to declare the variable and its type before using it in the subsequent code. The variable can take a value that matches with…

  • 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. PHP has a total of eight data types that we use to construct our variables − The first five are simple types, and the next two (arrays and objects) are compound types. The compound types can package up other arbitrary values of…

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