Skip to content

Instantly share code, notes, and snippets.

@dstogov
Created October 17, 2019 09:53
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 dstogov/d872b01acf2610d941072ee16f08cc98 to your computer and use it in GitHub Desktop.
Save dstogov/d872b01acf2610d941072ee16f08cc98 to your computer and use it in GitHub Desktop.
<?php
class Foo {
public ?string $p;
}
$a = new Foo;
$ref = &$a->p;
$ref[] = "bar";
echo "OPS!\n";
<?php
$a = new class {
public int $foo = 1;
};
$_ = [&$a->foo];
$_[0] += 1;
var_dump($a->foo);
$_[0] .= "1";
var_dump($a->foo);
$_[0] .= "e50";
var_dump($a->foo);
<?php
$a = new class {
public int $foo = 1;
};
$_ = &$a->foo;
$_ += 1;
var_dump($a->foo);
$_ .= "1";
var_dump($a->foo);
$_ .= "e50";
var_dump($a->foo);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment