phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


PHP Basic: Juggling Type

Tag: data type, juggling   Category: PHP Basic
post: 01 Mar 2008 read: 168


PHP Basic Data Type Step By Step Tutorial - Part 9: Variable type in PHP is determined by the context where the variable is used. For example, if a variable is filled with an integer number, so the variable becomes to have integer type.

For example, if some of the operand has the type of float, then all operand will be evaluated as float, so the result will become float type. It means that, the changing type from operand is how the operand be evaluated by a certain operator.

Pay attention to the example of using of juggling at script as follow:
File name: juggling.php


<html>
<head>
<title>Juggling Type</title>
</head>
<body>
<h1>Juggling Type</h1>
<? 
$a = "0";
echo "\$a = $a"."<br>";
$a += 7;
echo "\$a = $a"."<br>";
$a = $a + 1.3;
echo "\$a is float = $a"."<br>";
$a = 7 + "10 pack";
echo "\$a is integer = $a"."<br>";
$a = 5 + "15 pack";
echo "\$a is integer = $a"."<br><br><br>";

$b=3000;
$c=30;
$d=$b.$c;
echo "\$b = $b"."<br>";
echo "\$c = $c"."<br>";
echo "\$d = $d";
?>
</body>
</html>
php basic juggling type



| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
mod_rewrite - Part 1: create your "fantasy" URL

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


615
posting