Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // $name = 'Don';
- // echo 'My name is ' . $name;
- // echo '<br />';
- // echo $name . ' is my first name';
- // echo '<br /><br />';
- ?>
- <!--
- <form method="GET">
- <input type="text" name="person" />
- <button type="submit">Submit</button>
- </form>
- -->
- <?php
- // $name = $_GET['person'];
- // echo $name . ' is a Web Developer.';
- // this is single line comment.
- /* This
- is
- Multiline
- Comment
- */
- // PHP FUNCTIONS
- // 1. Built-in functions / Pre determined functions
- // 2. User Defined Functions
- // $name = 'John Wick is a king';
- // echo strlen($name) . '<br />';
- // echo str_word_count($name) . '<br />';
- // echo strrev($name) . '<br />';
- // echo strpos($name, 'is') . '<br />';
- // echo str_replace('is', 'was', $name) . '<br />';
- // PHP DATA TYPES
- // 1. String : $name = 'This is a string';
- // 2. Integer : $integer = 55;
- // 3. Float : $float 55.234234;
- // 4. Boolean : True = 1 or False = 0;
- // 5. Array : $array = array('One', 'Two', 'Three', '4');
- // $array = array('One', 'Two', 'Three', 4);
- // $array = ['One', 'Two', 'Three', 'Four'];
- // echo $array[3];
- // PHP OPERATORS
- /*
- 1. Arithmetic Operators
- 2. Assignment Operators
- 3. Comparison Operators
- 4. Increment / Decrement Operators
- 5. Logical Operators
- 6. String Operators
- 7. Array Operators
- 1. Arithmetic Operators
- + Addition $x + $y Sum of $x and $y
- % Modulus $x % $y Reminder of $x divided by $y
- ** Exponentiation $x ** $y Result of raising $x to the $y'th power
- */
- // echo 5 ** 2;
- // 2. Assignment Operators
- // = : $x = $y
- // += $x = $x + $y
- // -= $x = $x - $y
- // *= $x = $x * $y
- // /= $x = $x / $y
- // %= $x = $x % $y
- // **= $x = $x ** $y
- // $x = 2;
- // $y = 5;
- // echo $x **= $y;
- // 3. Comparison Operators
- // == $x == $y Returns true if $x is equal to $y
- // === $x === $y Returns true if $x is equal to $y and of the same type
- // != $x != $y Returns true if $x is not equal to $y
- // <> $x <> $y Returns true if $x is not equal to $y
- // !== $x !== $y Returns true if $x is not equal to $y and data type is not same
- // > $ > $y
- // <
- // <=
- // >=
- $x = 5;
- $y = 3;
- if ($x <> $y) {
- echo 'True';
- } else {
- echo 'False';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement