Category: Basic

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

  • Constants

    A constant in PHP is a name or an identifier for a simple value. A constant value cannot change during the execution of the PHP script. It basically improves code readability and maintainability. Constants make it easier to manage the configuration settings. They make code easier to read and prevent key values from changing. Constants…

  • $ and $$ Variables

    PHP is a powerful scripting language created specifically for web development. One of its unique features is the use of variables. Variables in PHP begin with the dollar symbol ($). But there is another type of variable known as a $$ (double dollar sign) variable, which is a variable within itself. In this chapter, we…

  • var dump Function

    The PHP Variable Handling var_dump() function is used to display structured information such as type and the value of one or more expressions given as arguments to this function. This function returns all the public, private and protected properties of the objects in the output. The dump information about arrays and objects is properly indented to show…

  • Echo and Print

    PHP uses the echo and print statements to display output in the browser or the PHP console. Both are language structures rather than functions, indicating that they are part of the PHP language. As a result, using parentheses is optional. These instructions are commonly used to display text, numbers, variables and even HTML content directly on a website. While…

  • Variables

    Variables in PHP are used to store data that can be accessed and modified across the program. A variable can store a wide range of values, like numbers, text, arrays and even objects. One of PHP’s unique features is that it is a loosely typed language, which means you are not required to declare the…