Category: PHP

  • PHP Functions

    by

    in

    PHP Built-in Functions A function is a self-contained block of code that performs a specific task. PHP has a huge collection of internal or built-in functions that you can call directly within your PHP scripts to perform a specific task, like gettype(), print_r(), var_dump, etc. Please check out PHP reference section for a complete list of useful PHP…

  • PHP Loops

    by

    in

    Different Types of Loops in PHP Loops are used to execute the same block of code again and again, as long as a certain condition is met. The basic idea behind a loop is to automate the repetitive tasks within a program to save the time and effort. PHP supports four different types of loops.…

  • PHP Sorting Arrays

    by

    in

    PHP Functions For Sorting Arrays In the previous chapter you’ve learnt the essentials of PHP arrays i.e. what arrays are, how to create them, how to view their structure, how to access their elements etc. You can do even more things with arrays like sorting the elements in any order you like. PHP comes with…

  • PHP Arrays

    by

    in

    What is PHP Arrays Arrays are complex variables that allow us to store more than one value or a group of values under a single variable name. Let’s suppose you want to store colors in your PHP script. Storing the colors one by one in a variable could look something like this: Example But what,…

  • PHP Switch…Case Statements

    by

    in

    PHP If…Else Vs Switch…Case The switch-case statement is an alternative to the if-elseif-else statement, which does almost the same thing. The switch-case statement tests a variable against a series of values until it finds a match, and then executes the block of code corresponding to that match. switch(n){case label1:        // Code to be executed if n=label1        break;case label2:        // Code…

  • PHP Operators

    by

    in

    What is Operators in PHP Operators are symbols that tell the PHP processor to perform certain actions. For example, the addition (+) symbol is an operator that tells PHP to add two variables or values, while the greater-than (>) symbol is an operator that tells PHP to compare two values. The following lists describe the…

  • PHP Strings

    by

    in

    What is String in PHP A string is a sequence of letters, numbers, special characters and arithmetic values or combination of all. The simplest way to create a string is to enclose the string literal (i.e. string characters) in single quotation marks (‘), like this: $my_string = ‘Hello World’; You can also use double quotation marks…

  • PHP Data Types

    by

    in

    Data Types in PHP The values assigned to a PHP variable may be of different data types including simple string and numeric types to more complex data types like arrays and objects. PHP supports total eight primitive data types: Integer, Floating point number or Float, String, Booleans, Array, Object, resource and NULL. These data types…

  • PHP Echo and Print Statements

    by

    in

    The PHP echo Statement The echo statement can output one or more strings. In general terms, the echo statement can display anything that can be displayed to the browser, such as string, numbers, variables values, the results of expressions etc. Since echo is a language construct not actually a function (like if statement), you can use it…

  • PHP Constants

    by

    in

    What is Constant in PHP A constant is a name or an identifier for a fixed value. Constant are like variables, except that once they are defined, they cannot be undefined or changed (except magic constants). Constants are very useful for storing data that doesn’t change while the script is running. Common examples of such data…