PHP code example of orklah / psalm-insane-comparison

1. Go to this page and download the library: Download orklah/psalm-insane-comparison library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

orklah / psalm-insane-comparison example snippets


$a = 'banana';
$b = 0;
if($a == $b){
    echo 'PHP 7 will display this';
}
else{
    echo 'PHP 8 will display this instead';
}

$a = 'banana';
$b = 0;
if($a === $b){
    echo 'This is impossible';
}
else{
    echo 'PHP 7 and 8 will both display this';
}

$a = 'banana';
$b = 0;
if((int)$a == $b){
    echo 'PHP 7 and 8 will both display this';
}
else{
    echo 'This is impossible';
}

$a = 'banana';
$b = 0;
if($a == (string)$b){
    echo 'This is impossible';
}
else{
    echo 'PHP 7 and 8 will both display this';
}

$a = 'banana';
/** @var positive-int $b */
if($a == $b){
    echo 'This is impossible';
}
else{
    echo 'PHP 7 and 8 will both display this';
}

/** @var numeric-string $a */
$b = 0;
if($a == $b){
    echo 'PHP 7 and 8 will both display this depending on the value of $a';
}
else{
    echo 'PHP 7 and 8 will both display this depending on the value of $a';
}