Skip to content

Instantly share code, notes, and snippets.

@ilhamarrouf
Created February 27, 2017 04:04
Show Gist options
  • Save ilhamarrouf/fa5f22da673cf5b44fbf81c229292573 to your computer and use it in GitHub Desktop.
Save ilhamarrouf/fa5f22da673cf5b44fbf81c229292573 to your computer and use it in GitHub Desktop.
OOP PHP
<?php
class test
{
public $a;
private $b;
function __construct($a, $b)
{
$this->a = $a;
$this->b = $b;
}
}
$a = new test("ankur" , "techflirt");
$b = $a; //Copy of the object
$a->a = "no Ankur";
print_r($a);
print_r($b);
?>
// Result of print_r
test Object
(
[a] => no Ankur
[b:test:private] => techflirt
)
test Object
(
[a] => no Ankur
[b:test:private] => techflirt
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment