Php - Variable

> Procedural Languages > Php

1 - Scope

private/protected properties are preceded with an underscore to make it obvious that they're not public. E.g.

  • private $_arr = array()
  • or public $arr = array()

2 - Print

print_r with true

3 - Passing Variable by Reference

function myFunction($name, &$data) {
 
        $this->name = $name; // name data will be copied
        $this->data = &$data; // whereas this->data will get a reference (ie location) to $data
 
}
Advertising