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, 4814👍, 0💬
Popular Posts:
Can you explain why your project needed XML? Remember XML was meant to exchange data between two ent...
The object that contains all the properties and methods for every ASP.NET page, that is built is .. ...
What does AddressOf operator do in background ? The AddressOf operator creates a delegate object to ...
I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, ...
When should the method invokeLater() be used? This method is used to ensure that Swing components ar...