humanware

php_training_day5_test

Aug 7th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.17 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6.     <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7.     <title>Test</title>
  8. </head>
  9. <body>
  10.     <ul>
  11.         <li>1. Open PHP Tag and Create a Variable</li>
  12.         <li>2. Create a Constant</li>
  13.         <li>3. Define 'x' variable and assign a value to it</li>
  14.         <li>4. Define 'y' variable and assign a value to it. </li>
  15.         <li>5. Do numeric operations (+, -, *, /, %) in 'x' and 'y'</li>
  16.         <li>6. Check if 'x' is greater than or equal to 'y'</li>
  17.         <li>7. Create a array and display it's values</li>
  18.         <li>8. Assign 'I live in Kathmandu, Capital of Nepal.' and count it's characters</li>
  19.         <li>9. Display 'Not equal' if 'x' is not equal to 'y'</li>
  20.         <li>10. Create a variable 'color' and check display it's name using switch statement</li>
  21.     </ul>
  22.  
  23.     <?php
  24.     //1.
  25.     $name = "alisa";
  26.     echo $name;
  27.    
  28.     echo '<br/><br/>';
  29.    
  30.     //2.
  31.     define('VECHILE_NAME', 'toyota');
  32.     echo VECHILE_NAME;
  33.    
  34.     echo '<br/><br/>';
  35.  
  36.     //3.
  37.     $x = 4;
  38.     $y = 4;
  39.  
  40.     echo $x . '<br />';
  41.    
  42.     $x = $x + $y;
  43.  
  44.     echo $x . '<br /><br />';
  45.    
  46.     echo $x + $y . '<br/>';
  47.     echo $x - $y . '<br/>';
  48.     echo $x * $y .  '<br/>';
  49.     echo $x / $y . '<br/>';
  50.     echo $x % $y . '<br/>';
  51.  
  52.     //6.
  53.     if($x >= $y) {
  54.         echo "x is greater then y";
  55.     } else {
  56.         echo "x is smaller then y";
  57.     }
  58.     echo '<br/><br/>';
  59.  
  60.     //7.
  61.     $name = array('alisa','suman','ram');
  62.     foreach($name as $nam)
  63.     {
  64.         echo $nam . '<br/><br/>';
  65.     }
  66.    
  67.     echo '<br/>';
  68.     //8.
  69.     $string = 'I live in Kathmandu, Capital of Nepal';
  70.     echo strlen($string);
  71.  
  72.     echo '<br/><br/>';
  73.  
  74.     //9.
  75.     if($x != $y){
  76.         echo "Not equal";
  77.     }
  78.     echo '<br/><br/>';
  79.  
  80.     //10.
  81.     $color = 'blue';
  82.     switch($color){
  83.         case 'red':
  84.             echo "red";
  85.             break;
  86.  
  87.         case 'blue':
  88.             echo "blue";
  89.             break;
  90.  
  91.         default:
  92.             echo "no color found";
  93.     }
  94. ?>
  95. </body>
  96. </html>
Advertisement
Add Comment
Please, Sign In to add comment