Variables

  • Begin with a $
  • Followed by name, starting with a letter or _underscore
  • Case sensitive
  • Cannot use $this, reserved for OOP
  • Don't need to be declared
  • Initialised at use
  • Assigned with a single equals sign =

 

Assigned by Value

 

$myVar = 10 ;

$yourVar = "Potato" ;

 

 

Assigned by Reference

 

Prefix & ampersand to variable being referenced

 

$potatoVar = &$yourVar ;

 

Any changes to the original or referenced variable will be seen in each other. i.e. if you change one, then you change them all

Leave a Reply