Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
How To Convert Numbers to Strings
How To Convert Numbers to Strings? - PHP Script Tips - Understanding String Literals and Operations
✍: FYIcenter.com
In a string context, PHP will automatically convert any numeric value to a string. Here is a PHP script examples:
<?php
print(-1.3e3);
print("\n");
print(strlen(-1.3e3));
print("\n");
print("Price = $" . 99.99 . "\n");
print(1 . " + " . 2 . " = " . 1+2 . "\n");
print(1 . " + " . 2 . " = " . (1+2) . "\n");
print(1 . " + " . 2 . " = 3\n");
print("\n");
?>
This script will print:
-1300 5 Price = $99.99 3 1 + 2 = 3 1 + 2 = 3
The print() function requires a string, so numeric value -1.3e3 is automatically converted to a string "-1300". The concatenation operator (.) also requires a string, so numeric value 99.99 is automatically converted to a string "99.99". Expression (1 . " + " . 2 . " = " . 1+2 . "\n") is a little bit interesting. The result is "3\n" because concatenation operations and addition operation are carried out from left to right. So when the addition operation is reached, we have "1 + 2 = 1"+2, which will cause the string to be converted to a value 1.
2007-04-20, 5094👍, 0💬
Popular Posts:
What Is the "@SuiteClasses" Annotation? "@SuiteClasses" is a class annotation defined in JUnit 4.4 i...
What Tools to Use to View HTML Documents? The basic tool you need to view HTML documents is any Web ...
How To View All Columns in an Existing Table? - Oracle DBA FAQ - Managing Oracle Database Tables If ...
What is the difference between include directive & jsp:include action? Difference between includ...
it will be very helpful if you send some important Questions with Answers of DBMS Tell us what types...