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, 4856👍, 0💬
Popular Posts:
How To Test Transaction Isolation Levels? - MySQL FAQs - Transaction Management: Commit or Rollback ...
If we have multiple AFTER Triggers on table how can we define the sequence of the triggers ? If a ta...
What is the purpose of the wait(), notify(), and notifyAll() methods? The wait(),notify(), and notif...
How To Empty Your Recycle Bin? - Oracle DBA FAQ - Managing Oracle Database Tables If your recycle bi...
How can we implement singleton pattern in .NET? Singleton pattern mainly focuses on having one and o...