Skip to content

Instantly share code, notes, and snippets.

@ksomemo
Created February 16, 2014 08:59
Show Gist options
  • Save ksomemo/9031411 to your computer and use it in GitHub Desktop.
Save ksomemo/9031411 to your computer and use it in GitHub Desktop.
<?php
class SimpleClass
{
public $str = 'a';
public $int = 1;
public $float = 1.0;
public $ary = array();
public $clsSame = null;
public $clsOther = null;
public $func = null;
public function pubFun() {}
private function priFun() {}
private $private = 'private';
private function proFun() {}
protected $protected = 'protected';
}
$class = new SimpleClass();
$class->func = function() {};
$class->clsSame = $class;
$class->clsOther = new SimpleClass();
var_dump($class);
@ksomemo
Copy link
Author

ksomemo commented Feb 16, 2014

% php -v
PHP 5.4.9 (cli) (built: Dec  2 2012 17:44:17) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
    with Xdebug v2.3.0dev, Copyright (c) 2002-2012, by Derick Rethans
% php SimpleClass.php      
class SimpleClass#1 (9) {
  public $str =>
  string(1) "a"
  public $int =>
  int(1)
  public $float =>
  double(1)
  public $ary =>
  array(0) {
  }
  public $clsSame =>
      ...

  public $clsOther =>
  class SimpleClass#3 (9) {
    public $str =>
    string(1) "a"
    public $int =>
    int(1)
    public $float =>
    double(1)
    public $ary =>
    array(0) {
    }
    public $clsSame =>
    NULL
    public $clsOther =>
    NULL
    public $func =>
    NULL
    private $private =>
    string(7) "private"
    protected $protected =>
    string(9) "protected"
  }
  public $func =>
  class Closure#2 (0) {
  }
  private $private =>
  string(7) "private"
  protected $protected =>
  string(9) "protected"
}

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