Looking for a Tutor Near You?

Post Learning Requirement »
x

Choose Country Code

x

Direction

x

Ask a Question

x

Hire a Tutor

Introduction To PHP

Loading...

Published in: PHP And MySQL
910 Views

PHP stands for Hypertext Preprocessor. These notes give a slight introduction to PHP.

Neelam S / Ghaziabad

1 year of teaching experience

Qualification: B.Tech

Teaches: Basic Computer, MS Office, School Level Computer, Computer Science, IT & Computer Subjects, Chemistry, Mathematics, Social Studies, CSS Training, HTML Training, PHP And MySQL

Contact this Tutor
  1. Class 4 PHP Loop Types: Loops in PHP are used to execute the same block of code a specified number of times. Decision Making: The if, elseif ...else and switch statements are used to take decision based on the different condition. if...else statement — use this statement if you want to execute a set of code when a condition is true and another if the condition is not true elseif statement — is used with the if...else statement to execute a set of code if one of the several condition is true switch statement — is used if you want to select one of many blocks of code to be executed, use the Switch statement. The switch statement is used to avoid long blocks of if..elseif..else code. The if.....else Statement: For example: < ?php if echo "Have a nice weekend! else echo "Have a nice day! The elseif Statement: For example: < ?php $d=date("D"); if echo "Have a nice weekend!"•
  2. elseif ($d==" Sun") echo "Have a nice Sunday!" else echo "Have a nice day!"• The switch statement: For example: < ?php switch ($d) case "Mon" echo "Today is Monday"; break; case "Tue". echo "Today is Tuesday"; break; case "Wed". echo "Today is Wednesday"; break; case "Thu": echo "Today is Thursday"; break; case "Fri". echo "Today is Friday"; break; case "Sat": echo "Today is Saturday"; break; case "Sun". echo "Today is Sunday";
  3. break; default: echo "Wonder which day is this 9." • While Loops: It loops through a block of code if and as long as a specified condition is true. For example: < ?php $num = 50; while( $i < 10) $num--; echo ("Loop stopped at i = $i and num = $num" ); Do..while Loop: The do...while statement will execute a block of code at least once - it then will repeat the loop as long as a condition is true. For example: < ?php $num = 0; do { } while( $i < 10 ); echo ("Loop stopped at i = $i" ); For Loop: The for statement is used when you know how many times you want to execute a statement or a block of statements.
  4. For example: < '?php for( $i
  5. while( $i < 10) if( $i == 3 )break; echo ("Loop stopped at i = $1 ) Continue Statement: The PHP continue keyword is used to halt the current iteration of a loop but it does not terminate the loop. Just like the break statement the continue statement is situated inside the statement block containing the code that the loop executes, preceded by a conditional test. For the pass encountering continue statement, rest of the loop code is skipped and next pass starts. For example: < ?php $array = array( 1, 2, 3, 4, 5); foreach( $array as $value ) if( $value 3 )continue; echo "Value is $value