易截截图软件、单文件、免安装、纯绿色、仅160KB

PHP Floating point precision

Floating point precision
It is typical that simple decimal fractions like 0.1
or
0.7
cannot be converted into their internal binary
counterparts without a small loss of precision. This can lead to
confusing
results: for example, floor((0.1+0.7)*10)
will usually
return 7
instead of the expected 8
,
since the internal representation will be something like
7.9
.

 
This is due to the fact that it is impossible to express some
fractions in decimal notation with a finite number of digits. For
instance,
1/3
in decimal form becomes
0.3
.

 
So never trust floating number results to the last digit, and never
compare
floating point numbers for equality. If higher precision is
necessary,
the arbitrary
precision math functions
and
gmp
functions are available.


相关文档:

JAVA和PHP文件操作总结

JAVA文件操作总结
File类
File f = new File(path);
path为实际路径,该路径可以是文件,或文件夹,也可以是不存在的。
f.exists() 可以判断该路是否存在。
f.isDirectory() 可以判断是否是文件夹。
f.mkdirs(); 递归创建文件夹
File和输入输出流之间纽带FileInutStream,FileOutputStream
URL url = new URL(strUr ......

PHP 制作通讯录(五)

通讯录已经大致完成了,但如果记录数多时,查找起来很不方便,如果加一个搜索功能就好了。今天我们就来制作一个搜索功能
在Index.php合适的地方加入搜索框
 <!---搜索框--->
<!--这里的所有值前面加前缀“S_”以区分-->
<form id="form1" name="form1" method="post" action="Search.php ......

php有关的几种常见安全详解

(1) 打开php的安全模式
php的安全模式是个非常重要的内嵌的安全机制,能够控制一些php中的函数,比如system(),
同时把很多文件操作函数进行了权限控制,也不允许对某些关键文件的文件,比如/etc/passwd,
但是默认的php.ini是没有打开安全模式的,我们把它打开:
safe_mode = on
(2) 用户组安全
当safe_mode打开时, ......

PHP 判断FORM来的数据是否为整数

is_int函数对于FORM过来的数据是没有办法判断是否是整数的,因为FORM过来的是字符串。用is_numeric可以判断是否为数字类型,稍动 下手脚就可以判断是不是整数了
if(!is_numeric($jp_total)||strpos($jp_total,".")!==false){
echo "不是整数";
}else{
echo "是整数";
} ......

PHP后台程序对LINUX信号的处理

PHP在运行的时候,直接kill掉,有肯能造成数据的丢失。幸好php模块,有针对signal的处理。
处理方式,首先检查有没有安装 PCNTL 模块
然后可以在一个包含文件中,添加以下代码
global $exitFlag;
$exitFlag = false;
// 增加linux信号量处理
if (DIRECTORY_SEPARATOR != '\\') {
    pcntl_signal(SI ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号