June 12, 2002, 10:01:52 pm
<--PreviousNext -->

Types and Variables

  • boolean
  • integer
  • floating-point number (double)
  • string
  • array
  • object
  • resource
  • NULL
The type of a variable is usually not set by the programmer; rather, it is decided at runti me by PHP depending on the context in which that variable is used.

If you would like to force a variable to be converted to a certain type, you may either cast the variable or use the settype() function on it.

PHP does not require (or support) explicit type definition in variable declaration; a variable's type is determined by the context in which that variable is used. That is to say, if you assign a string value to variable var, var becomes a string. If you then assign an integer value to var, it becomes an integer.

  • Variables in PHP are represented by a dollar sign followed by the name of the variable. The variable name is case-sensitive.
  • Starting with PHP4 variables can be passed to function by value or by reference:


	// Pass by value
	call_function ($var1, $var2);

	// Pass by reference
	call_function (&$var1, &$var2);