Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- . concatenate Combine $x & $y
- .= concatenate assignment append $x & y
- $x = 'Test';
- $y = 'Test 2';
- echo $x .= ' Test 3';
- // echo $x . ' ' . $y;
- $header = 'CC: [email protected]';
- $header .= 'BCC: [email protected]';
- echo $header;
- */
- /*
- ARRAY OPERATORS
- To compare arrays
- + Union $x + $y Union of $x and $y
- == Equality $x == $y Returns true if $x & $y have same key/value pairs.
- === Identity $x === $y Returns true if $x & $y have the same key/value pairs in same order and same type
- != Inequality $x != $y Returns true if $x is not equal to $y
- <> Inequality $x <> $y Returns true if $x is not equal to $y
- !== Not Identity $x !== $y Returns true if $x is not identical to $y
- $x = array('a' => 'red', 'b' => 'green');
- $y = array('c' => 'blue', 'd' => 'orange');
- var_dump($x !== $y);
- CONSTANTS
- define('COUNTRY_NAME', 'Nepal');
- echo COUNTRY_NAME;
- CONDITIONAL STATEMENTS
- 1. If Statement
- if (condition) {
- code block
- }
- 2. If Else
- if (condition) {
- this code block runs
- } else {
- this code block runs
- }
- 3. If Else-If Statement
- if (condition) {
- code
- } elseif (condition) {
- code
- } elseif (condition) {
- code
- } else {
- code
- }
- $result = 80;
- if ($result = 70) {
- echo 'Grade A';
- } elseif ($result >= 60) {
- echo 'Grade B';
- } else {
- echo 'Pass';
- }
- TERNARY OPERATORS
- one line if else
- $var = 1;
- $var_is_greater_than_two = ($var > 2 ? true : false);
- var_dump($var_is_greater_than_two);
- SWITCH STATEMENTS
- */
- $num = 'Test Number';
- switch ($num) {
- case 'Test Number':
- echo 'One';
- break;
- case 2:
- echo 'Two';
- break;
- case 3:
- echo 'Three';
- break;
- default:
- echo 'No Number';
- }
Advertisement
Add Comment
Please, Sign In to add comment