Learn PHP in 24 Hours

SAMS Teach Yourself PHP in 24 Hours, 3rd Edition courtesy of the Association for Computing Machinery

This post was created as a reference point.

PHP Standard Data Types

There are 6 standard data types in PHP. They are:

  • Integer
  • Double
  • String
  • Boolean
  • Object
  • Array
  • There are also 2 Special Data Types. They are:

  • Resource
  • Null
  • Testing for a specific data type.

    Functions to test data types

  • is_array()
  • is_bool()
  • is_double()
  • is_int()
  • is_object()
  • is_string()
  • is_null()
  • is_resource()
  • Operators and Expressions

    An operator is a symbol or series of symbols that, when used in conjunction with values, performs an action and usually produces a new value.

    An operand is a value used in conjunction with an operator. There are usually two operands to one operator.

    An expression is any combination of functions, values, and operators that resolves to a value. As a rule of thumb, if you can use it as if it were a value, it is an expression.

    The concatenation operator is a single period (.).
    “hello”.” world”

    Constants

    You must use PHP’s built-in function define() to create a constant.

    Functions

    A function is a self-contained block of code that can be called by your scripts. When called, the function’s code is executed. You can pass values to functions, which they then work with. When finished, a function can pass a value back to the calling code.

    To define a function:
    function my_function( $my_argument1, $my_argument2 ) {
    // function code here
    }

    References

  • http://my.safaribooksonline.com/book/programming/php/0672326191
  • http://www.acm.org/
  • http://www.elementk.com/
  • 0
      Related Posts