| | |
Variable typing in PHP?
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Aug 2006
Posts: 999
Reputation:
Solved Threads: 1
I know, I know, one of the big advantages of PHP is that the variables in PHP don't take typecasting but instead any variable can hold any data. Thing is, for something I'm trying right now I need the ability to cast. I'm trying to add together financial values drawn from a database, which means they're all floating-point with two significant digits after the decimal. Problem is, actually doing addition on them seems to deal with integer addition; if the values both end in .*0, then any zeroes after the decimal point are eliminated from the value before it gets displayed on the resulting page. Is there any way in PHP to code for a financial numeric typecast, or am I going to have to hack around it with stringlength comparisons and artifical trailing zeroes?
John Conde
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
•
•
Join Date: Aug 2006
Posts: 138
Reputation:
Solved Threads: 2
You may also wanna check out: http://www.php.net/manual/en/function.number-format.php
![]() |
Similar Threads
- how do i use php?id and what are they? (PHP)
- Opinions? javascript/php/etc and programming standards (JavaScript / DHTML / AJAX)
- POST with header (PHP)
- New to php and getting frustrated (HTML and CSS)
- Multiple PHP INCLUDES (PHP)
Other Threads in the PHP Forum
- Previous Thread: php uploader script
- Next Thread: PHP for login authentication
Views: 1552 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date datepart directory display download dynamic echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla jquery limit link list login loop mail menu methods mlm mod_rewrite multiple mysql oop parse password paypal pdf php problem query radio random recursion regex remote script search select seo server sessions sms soap source space speed sql structure syntax system table tutorial update updates upload url validation validator variable video web webdesign xml youtube






