PHP  
downloads | documentation | faq | getting help | mailing lists | | php.net sites | links 
search for in the  
previousCommentiBooleansnext
Last updated: Tue, 03 Sep 2002
view the printer friendly version or the printer friendly version with notes or change language to English | Brazilian Portuguese | Chinese | Czech | Dutch | Finnish | French | German | Hungarian | Japanese | Korean | Polish | Romanian | Russian | Spanish | Swedish | Turkish

Capitolo 7. Types

Introduction

PHP supports eight primitive types.

Four scalar types:

Two compound types:

And finally two special types:

Nota: In this manual you'll often find mixed parameters. This pseudo-type indicates multiple possibilities for that parameter.

The type of a variable is usually not set by the programmer; rather, it is decided at runtime by PHP depending on the context in which that variable is used.

Nota: If you want to check out the type and value of a certain expression, use var_dump().

If you simply want a human-readable representation of the type for debugging, use gettype(). To check for a certain type, do not use gettype(), but use the is_type functions.

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.

Note that a variable may behave in different manners in certain situations, depending on what type it is at the time. For more information, see the section on Type Juggling.

User Contributed Notes
Types
add a note about notes
[email protected]
06-Jun-2001 07:02

To see if something is numeric (a number) then use is_numeric(). All form data is returned as strings so checking a form value as an integer will return false.


[email protected]
22-Mar-2002 03:39

Be carefull! Comparison of any string with integer zero returns TRUE. For example 'hello'==0 is TRUE.
03-Jul-2002 02:22
But 'hello' === 0 is not, === makes sure that they are equivilent and of the same type.
add a note about notes
previousCommentiBooleansnext
Last updated: Tue, 03 Sep 2002
show source | credits | stats | mirror sites
Copyright © 2001, 2002 The PHP Group
All rights reserved.
This mirror generously provided by:
Last updated: Thu Sep 5 20:07:53 2002 CEST