PHP - Post & Pre Increment & Decrement

This is a quite shorter way to add 1 to or subtract 1  from a variable. 

Increment Operator
     "++" uses to increase 1

Decrement Operator
     "--" uses to decrease 1

     Ex:
        $no1 = 5;
        $no1++; // This is equal to $no1 = $no1 + 1;
        $no1--; // This is equal to $no1 = $no1 - 1;
  • There is a difference when the increment operator uses before the variable and after the variable. If the operator uses before the variable then the value get after increasing the variable value. But put the increment operator after the variable then 1st it print the variable value and then increase the value by 1.
         Ex:

PHP - String Operators

The Period "." operator used to concatenate two or more strings together.

Ex:

<?php

     $text1 = "Programming Languages";
     $text2 = "for Beginners";
     echo $text1 . " " . $text2; // Two string variables and a space join together
?> 

PHP - Heredoc String Creation

PHP traditional string creation method I've mentioned in earlier post. That method common to most of the programming languages. PHP introduces a more robust string string creation tool called Heredoc, it creates multi-line strings without using single or double quotes. This methods seems to be easy but it's too difficult and can be lead to arise errors if you do not properly code the string.

PHP - Conditional Statements

Conditional Statements are used to perform different actions based on the conditions.

In PHP, there are few conditional statements are used to do that.
  • If Statement
    Perform some actions if the condition is true.
  • If.. Else Statement
    Perform some actions if the condition is true and another actions if its false.
  • If... ElseIf Statement
    Perform some actions according to the conditions provided
  • Switch Statement
    Blocks of codes can be executed

PHP - Constants

PHP Constant is an identifier for a value like a variable but it has some unique characteristics such as,
  • Once you create a constant then you cant change it
  • Once you create a constant then you cant undefined it
  • Value cannot be changed during the  script
  • Constant Name starts with a Letter or underscore sign. There is no $ sign for constants.

How to set a PHP Constant
There is a key word calling "define" uses to define the constants in PHP.

PHP - How to read content of a file

PHP can read the content of files such as txt, doc, etc and can be displays it onto the web page as a HTML document.

Syntax:
  readfile(<filename>);