Total members 11895 |It is currently Sun Dec 22, 2024 5:05 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Code:
<?
$type_examples
[0] = 123;   
$type_examples[1] = 3.14159;
$type_examples[2] = "a string";
$type_examples[3] = "9.990 (begins with number)";
$type_examples[4] = array(9,8,7);
   
print(
"<TABLE><TR>");
print(
"<TH>Original</<TH>");
print(
"<TH>(int)</<TH>");
print(
"<TH>(double)</<TH>");
print(
"<TH>(string)</<TH>");
print(
"<TH>(array)</<TH></TR>");
   
for (
$index = 0; $index < 5; $index++){
    print(
"<TR><TD>$type_examples[$index]</TD>");
    
$converted_var =
       (int)
$type_examples[$index];
    print(
"<TD>$converted_var</TD>");
    
$converted_var =
       (double)
$type_examples[$index];
    print(
"<TD>$converted_var</TD>");
    
$converted_var =
       (string)
$type_examples[$index];
    print(
"<TD>$converted_var</TD>");
    
$converted_var =
       (array)
$type_examples[$index];
    print(
"<TD>$converted_var</TD></TR>");
  }
print(
"</TABLE>");
?>




_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : Type conversions
 Type Conversion     -  
 Testing the Type of a Variable     -  
 Is String a data type     -  
 String type default value     -  
 Data Type in Programming     -  
 range of the short type     -  
 range of the char type     -  
 Boolean type constant     -  
 range of data type     -  
 Create Object and get its type     -  



Topic Tags

PHP Basics, PHP Variables
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com