Posts

Current Date ,time ,day ,years Program

Image
Returning value          Some PHP function returns value when called and the nature of the returned value may be determined by the argument passed  .  for example            The built-in-date() function accept a whole range of argument to determine how date information should be formatted for return to the caller  Argument     Description                    Example      Y            Year as four digit              2020     y            Years as two digit                14             n            Month as one or two digit      7     m           Month as two digit    ...

Loops in PHP ( for , while , do while , foreach)

Image
Loops                A loop is a piece of code in a script automatically repeats . One complete execution of all statement within a loop is called an " iteration " or "pass" . The length of a loop is a controlled by a conditional test made within the loop  In PHP there are these four type of loop structure    1 . for loop - performs a specified number of iteration . 2 . while loop - performs iteration only while a test made at the start of each                          iteration evaluates as TRUE 3 . do while loop - performs iterations only while a test made at the end of each                     iteration evaluates as TRUE  4 . foreach loop - performs iteration through each element of an array  Syntax       for ( initializer ; test-expression ; increment )         ...

Switching Branches

Image
Switch Statements                Conditional branching performed by multiple if-elseif-else statement can often be performed more efficient by a switch statement when the test expression just evaluates one condition . The switch statement work in an unusual way . It takes a given value as its parameters argument  then seeks to match that value from a number of case statement . The important to end each case statement with a break keyword statement so the switch statement when then exit when a match is found without seeking further matches  Syntax      switch(test-value)         {            case match-value:statement-to-execute-when-matched ; break;             case match-value:statement-to-execute-when-matched ; break;             case match-value:statement-to-execute-when-matched ; break;       ...

Branching Alternatives if else Condition

Image
  if else Condition      The if keyword is used to perform the basic condition text that evaluates a given expression for a boolean value of TRUE or FALSE . Statement with in braces following the evaluation will only be exacuted when the expression is found to be true  Syntax     if (test expression)         {             statement to execute when true          } if statement by appending an else statement by appending an else statement specifying within braces to be executed when the expression evaluated by the if statement are found to be FALSE  Syntax         if(test-expression)         {              statement-to-executed-when-true         }   else         {             statement-to-executed-when-false      ...

Arithmetic in PHP

Image
      Arithmetic Operator                           The arithmetic operator commonly used in PHP script are listed in the table below together with the operator they performed                      Operator                              Operation                                         +                                       Addition                        -                                       Subtraction   ...

Arrays in PHP

Image
Producing Arrays         An array variable can store multiple items of data sequential array elements that are number starting at zero . So the first array is value stored in array element number zero Individual array elements value can be referenced using the variables name followed by the index number in square brackets .        for example                 $months[0] reference value stored in the first  array element                 $months[1] reference value stored in second array element  Variable array can be created multiple statement that assign value to successive element        array() function to fill the element  for example          $months[]='January';         $months[]='February';         $months[]='March';         $months = a...

Creating Variables in PHP

Image
Creating Variables             A "variable" is a named container in a PHP script in which a  data value can be stored . The stored value can be referenced using the variables name and changed the script proceeds . The script author can chose any name for a variable providing it adheres to these naming convention . 1 . Name must begin with a $ (dollar sign)              for example                          $name 2 .  Name can comprise letters , numbers and underscore ,characters but not space                for example                                $total_1 3 . The first character after the $ dollar sign must  be a letter or an underscore character         - it can not be a number PHP are case-sensitiv...