
|
|
|||
Introduction to PHP ProgrammingBy PHP Catalyst2007-11-19
Data Types in PHP In PHP a variable can hold data of any type. These data types are as following:
Assigning data typesUnlike other programming languages, PHP does not require formal declaration of the data type of a variable. When you assign certain value to a variable, PHP will automatically try to guess the type of data being stored and assign the data type to the variable. When needed PHP will automatically convert the data type.
<?Here data type of $a is automatically converted to a real number and then added with the value of $b which is a real number too. Type CastingSometimes, there might be a need to change the data type of a certain variable from string to an integer and then back to a string. Such manual over riding of data types is called Type Casting. Since PHP will automatically change the data type, chances are rare that you will need to use type casting at all. To specify a different of a particular data type, use the following:
<?Determining Data TypeTo find out the data type of a variable, use a statement like the following:
<?This will output the data type and value of the variable. In this case, the output will be int(100) Tutorial Pages: » What can I do with PHP? » Popoular Features of PHP » Basics of PHP » Variables in PHP » Data Types in PHP » Expressions and Operators » Control Structures in PHP » Functions in PHP » Declaring Functions in PHP » Scope of a Variable » Built-in Functions in PHP » Handling Strings in PHP » Printing Strings in PHP » String Comparisons in PHP » Manipulating Strings in PHP » Arrays in PHP » Types of Arrays in PHP » Creating Arrays in PHP » Array Operations in PHP |
||||
| About the NetVisits, Inc Network | Write For Us | Advertise Copyright ©2007 NetVisits, Inc Network. All Rights Reserved. Privacy Policy. |
Visit other NetVisits, Inc. sites: |