我在我的项目中使用imagefilledrectangle()
。第2,第3,第4和第5参数接受点坐标。函数描述指定的类型应为integer
。我的问题是,我在运行时计算这些并确保它们是整数是困难的。
我的问题:
使用'实数'有什么后果?而不是整数?例如:
imagefilledrectangle( $img, 1.2, 3.4, 4.5, 7.8, $color )
参考:http://php.net/manual/en/function.imagefilledrectangle.php
答案 0 :(得分:1)
如上所述,根据PHP的float-> int转换规则,你的浮点数将通过截断得到整数。所以函数调用实际上是
imagefilledrectangle( $img, 1, 3, 4, 7, $color )
由于函数explicitly defining的位置参数为int
。
e.g。
echo (int)7.8; // outputs '7'
echo (int)1.2; // outputs '1'