Posts

Showing posts from May, 2020

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...

Connecting MySQL with PHP

Image
Connection to a MySQL database can be attempted in PHP with a standard piece of script that describes four connection parameters of host , user name , password and database name . Upon failure the script provides a descriptive message , whereas on success it specifies the character set to be used when sending data to and from the database server                Query                 $connection = mysqli_connect ('localhost','username','password','database');                     You need not understand in details how the script works at this stage but recognize that it contains sensitive information . For this reason it should not be placed in the web server WWW directory like all others PHP script , where its contents may be accessible but placed instead safely in /WWW parent directory .   For Example           in the App Server d...

Make Your Own Website

Image
Introducing PHP & MySQL    What is PHP ?           PHP is a widely-used general purpose scripting language that is especially suited for web development and can be embedded into HTML . It was created by programmer Rasmus Lerdorf as a set of script to maintain his website that he released as "Personal Home Page"        What is MySQL ?                     MySQL is the world's most popular database software .  It is used to manage stored data is describe as Database Management Software (DBMS) or Relational Database Management Software (RDBMS). MySQL was created by Michael Wildenius and David Axmark back in 1995. HTTP Request & HTTP Response Figure