Advertisement
humanware

php_training_day_1

Aug 7th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.30 KB | None | 0 0
  1. <?php
  2.  
  3. // $name = 'Don';
  4. // echo 'My name is ' . $name;
  5. // echo '<br />';
  6. // echo $name . ' is my first name';
  7.  
  8. // echo '<br /><br />';
  9.  
  10. ?>
  11.  
  12. <!--
  13. <form method="GET">
  14.     <input type="text" name="person" />
  15.     <button type="submit">Submit</button>
  16. </form>
  17. -->
  18.  
  19. <?php
  20.  
  21. // $name = $_GET['person'];
  22. // echo $name . ' is a Web Developer.';
  23.  
  24. // this is single line comment.
  25.  
  26. /* This
  27. is
  28. Multiline
  29. Comment
  30. */
  31.  
  32.  
  33. // PHP FUNCTIONS
  34. // 1. Built-in functions / Pre determined functions
  35. // 2. User Defined Functions
  36.  
  37. // $name = 'John Wick is a king';
  38.  
  39. // echo strlen($name) . '<br />';
  40. // echo str_word_count($name) . '<br />';
  41. // echo strrev($name) . '<br />';
  42. // echo strpos($name, 'is') . '<br />';
  43. // echo str_replace('is', 'was', $name) . '<br />';
  44.  
  45. // PHP DATA TYPES
  46. // 1. String : $name = 'This is a string';
  47. // 2. Integer : $integer = 55;
  48. // 3. Float : $float 55.234234;
  49. // 4. Boolean : True = 1 or False = 0;
  50. // 5. Array : $array = array('One', 'Two', 'Three', '4');
  51.  
  52. // $array = array('One', 'Two', 'Three', 4);
  53. // $array = ['One', 'Two', 'Three', 'Four'];
  54. // echo $array[3];
  55.  
  56. // PHP OPERATORS
  57. /*
  58. 1. Arithmetic Operators
  59. 2. Assignment Operators
  60. 3. Comparison Operators
  61. 4. Increment / Decrement Operators
  62. 5. Logical Operators
  63. 6. String Operators
  64. 7. Array Operators
  65.  
  66. 1. Arithmetic Operators
  67.  
  68. +   Addition    $x + $y     Sum of $x and $y
  69. %   Modulus     $x % $y     Reminder of $x divided by $y
  70. **  Exponentiation  $x ** $y    Result of raising $x to the $y'th power
  71. */
  72.  
  73. // echo 5 ** 2;
  74.  
  75. // 2. Assignment Operators
  76. // = : $x = $y
  77. // +=       $x = $x + $y    
  78. // -=       $x = $x - $y
  79. // *=       $x = $x * $y
  80. // /=       $x = $x / $y
  81. // %=       $x = $x % $y
  82. // **=      $x = $x ** $y
  83.  
  84. // $x = 2;
  85. // $y = 5;
  86. // echo $x **= $y;
  87.  
  88. // 3. Comparison Operators
  89. // ==       $x == $y    Returns true if $x is equal to $y
  90. // ===      $x === $y   Returns true if $x is equal to $y and of the same type
  91. // !=       $x != $y    Returns true if $x is not equal to $y
  92. // <>       $x <> $y    Returns true if $x is not equal to $y
  93. // !==      $x !== $y   Returns true if $x is not equal to $y and data type is not same
  94. // >        $ > $y    
  95. // <      
  96. // <=
  97. // >=
  98.  
  99. $x = 5;
  100. $y = 3;
  101.  
  102. if ($x <> $y) {
  103.     echo 'True';
  104. } else {
  105.     echo 'False';
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement