Skip to content

Instantly share code, notes, and snippets.

@hemikak
Created January 24, 2018 11:53
Show Gist options
  • Save hemikak/561fd909a6dc8b62fb58759ab56ce1ff to your computer and use it in GitHub Desktop.
Save hemikak/561fd909a6dc8b62fb58759ab56ce1ff to your computer and use it in GitHub Desktop.
<?php
echo "Arrays" . "\xA";
// Arrays
$cars = array("Volvo","BMW","Toyota");
$cars2 = array("Volvo","BMW","Toyota");
$cars3 = array("Nissan","e","8");
var_dump($cars === $cars);
var_dump($cars === $cars2);
var_dump($cars === $cars3);
echo "\xA" . "Objects" . "\xA";
// Objects
class Car {
function Car($model) {
$this->model = $model;
}
}
// create an object
$herbie = new Car("VW");
$herbie2 = new Car("VW");
$toyota = new Car("TY");
// show object properties
var_dump($herbie === $herbie);
var_dump($herbie === $herbie2);
var_dump($herbie === $toyota);
@hemikak
Copy link
Author

hemikak commented Jan 24, 2018

Output:

Arrays
bool(true)
bool(true)
bool(false)

Objects
bool(true)
bool(false)
bool(false)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment