- Whole Numbers
Integer data type uses to store positive or negative whole Numbers (without decimal points). It is not required to define integers because php is a loosely typed language. You are define a whole number without double quotes then it automatically evaluate as an integer value. But you can force the value store as integer by using casting.Ex:
1, -50
$num = 50 // Numbers are define without double or single quotes
$num = (int) 50 // This is a casting example. Here force to store the value as integer.
$num = (int) "5years" // Taken the value as 5
$num = (int) "age10" // Taken the value as 0 - Real Numbers
Double and Float data type uses to store positive or negative whole Numbers (with decimal points).
Ex:
15.3325, -5.586240
$num = 50.5589// Real Numbers are define without double or single quotes
$num = (double) 50.569 // This is a casting example. Here force to store the value as real number.
$num = (double) "5.85Km" // Taken the value as 5.85
$num = (double) "age10.6" // Taken the value as 0
$num = (float) "10.53yards" // Taken the value as10.53
This blog supports beginners to get deep knowledge about programming in HTML, CSS, JavaScript, php, asp and other Web technologies and VB, VB.net, Java,step by step from the beginning. All the programming Concepts discuss with simple examples for the readability. Try out daily uploaded lessons to be a Programmer.
PHP - Numbers
There are two types of Numbers can be declared with php.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment