Skip to content

Instantly share code, notes, and snippets.

@polidog
Last active December 14, 2017 17:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save polidog/0e6c0bf63105fc279b16f06293427bad to your computer and use it in GitHub Desktop.
Save polidog/0e6c0bf63105fc279b16f06293427bad to your computer and use it in GitHub Desktop.
privateなプロパティにアクセスできるのか!!!
<?php
class Category
{
private $id;
public function __construct($id)
{
$this->id = $id;
}
public function equals(Category $category): bool
{
return $this->id === $category->id;
}
}
$c1 = new Category(1);
$c2 = new Category(1);
var_dump($c1->equals($c2));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment