Results: 1580
Notes
  • Newest first
  • Oldest first
  • Newest first(All)
  • Oldest first(All)
==
(Equal) Returns true if $x is equal to $y
$x = 40; 
$y = "40";
var_dump($x == $y); // true
===
(Identical) Returns true if $x is equal to $y, and they are of the same type
$x = 40; 
$y = "40";
var_dump($x === $y); // false
!=
(Not equal) Returns true if $x is not equal to $y
$x = 40; 
$y = "40";
var_dump($x != $y); // false
<>
(Not equal) Returns true if $x is not equal to $y
$x = 40; 
$y = "40";
var_dump($x <> $y); // false
!==
(Not identical) Returns true if $x is not equal to $y, or they are not of the same type
$x = 40; 
$y = "40";
var_dump($x !== $y); // true
>
(Greater than) Returns true if $x is greater than $y
$x = 40; 
$y = 50;
var_dump($x > $y); // false
<
(Less than) Returns true if $x is less than $y
$x = 40; 
$y = 50;
var_dump($x < $y); // true
>=
(Greater than or equal to) Returns true if $x is greater than or equal to $y
$x = 40; 
$y = 50;
var_dump($x >= $y); // false
<=
(Less than or equal to) Returns true if $x is less than or equal to $y
$x = 40; 
$y = 50;
var_dump($x <= $y); // true
by Valeri Tandilashvili
2 years ago
0
PHP
Operators
1
Logical operators are used to combine conditional statements.
and
($x and $y) True if both $x and $y are true
$x = 40; 
$y = 50;
if ($x > 30 and $y > 45) {
    echo "True";
}
or
($x or $y) True if either $x or $y is true
$x = 40; 
$y = 50;
if ($x > 30 or $y == 85) {
    echo "True";
}
xor
($x xor $y) True if either $x or $y is true, but not both
$x = 40; 
$y = 50;
if ($x > 30 xor $y == 85) {
    echo "True";
}
&&
($x && $y) True if both $x and $y are true
$x = 40; 
$y = 50;
if ($x > 30 and $y > 45) {
    echo "True";
}
||
($x || $y) True if either $x or $y is true
$x = 40; 
$y = 50;
if ($x > 30 or $y == 85) {
    echo "True";
}
!
(!$x) True if $x is not true
$x = 40;
if ($x !== 50) {
    echo "True";
}
by Valeri Tandilashvili
2 years ago
0
PHP
Operators
1
for cycle
for ($i = 0, i<10, i++){ echo "counter $i"; }
by guga muchiashvili
2 years ago
0
PHP
php note
1
for cycle with whyle operator
$ricxvi = 0; while($ricxvi < 10){ echo "another counter $ricxvi" ; $ricxvi ++; }
by guga muchiashvili
2 years ago
0
PHP
php note
1
The
break
statement is used to jump out of loops
for ($x = 0;  $x < 10;  $x++) {
  if ($x == 7) {
    break;
  }
  echo "$x"."\n";
}
Another example using
break
statement In this example prints numbers less than 6
for ($x = 0;  $x < 10;  $x++) {
  if ($x*$x > 30) {
    break;
  }
  echo "$x"."\n";
}
Uses
break
statement instead of for loop condition section
for ($i = 0;  ;  $i ++) {
  if ($i == 10) {
    break;
  }
  echo $i . "\n";
}
by Valeri Tandilashvili
2 years ago
0
PHP
Loops
1
The
continue
statement breaks only one iteration in the loop and continues with the next iteration
for ($x = 0;  $x < 10;  $x++) {
  if ($x == 7) {
    continue;
  }
  echo "$x"."\n";
}
echo "\n\n";
Prints Only numbers evenly divisible by 2
for ($x = 0;  $x < 10;  $x++) {
  if ($x%2 == 1) {
    continue;
  }
  echo "Example2: $x"."\n";
}
by Valeri Tandilashvili
2 years ago
0
PHP
Loops
1
global variable
<?php $age = 25 function getAge(){ echo $age; } getAge(); /* Output will be error , because we have $age variable out of the function and it isn't global variable.If we want to function has output we need to add a global variable (global $age ) to the function */ ?> <?php //exapmle of global variable $age = 25 function getAge(){ global $age; echo $age; } getAge(); //output will be 25 ?>
by ana meskhi
2 years ago
0
PHP
global
php
variable
1
variable variables
<?php // if we want to output variable variables value we use in echo two dollars sign $$ for example $fruit = 'apple'; $apple = "apple is fruit"; echo $$fruit; // output will be "apple is fruit" ?>
by ana meskhi
2 years ago
5
PHP
php
variable
variables
1
The difference between post-increment and pre-increment
<?php $x= 7; $y= $x ++ // $x = 8; $y = 7 $x= 7; $y= ++$x // $x = 8; $y = 8 ?>
by ana meskhi
2 years ago
0
PHP
post-decrement
post-increment
pre-decrement
pre-increment
1
The difference between operators (== and ===)
//if we use == sign it doesn't check the type of data apart from === sign which check also type of data <?php $a = 34; $b = 34; if($a == $b) { echo "Equal"; } else{ echo "Not Equal"; } //answer will be "Equal" true if('34' == 34){ echo "Equal"; } else{ echo "Not Equal"; } //answer will be "Equal" if('34' == 34){ echo "Equal"; } else{ echo "Not Equal"; } //answer will be "Not Equal" because types of variables isn't equal to each others ?>
by ana meskhi
2 years ago
0
PHP
1
Results: 1580