我正在使用 php 进行锻炼,现在遇到了问题
我的 php 代码是:
<?php
$random= rand (1,5)."Boys";
$random2= rand (1,5)."Girls";
$random3=$random.$random2;
imagettftext($jpg_image, 25, 0, 10,20, $white, $font_path, $random);
imagettftext($jpg_image, 25, 0, 100,200, $white, $font_path, $random2);
imagettftext($jpg_image, 25, 0, 275, 50, $white, $font_path,$random3);
?>
我还没有给出完整的编码,但我会向你解释我正在像男孩或女孩一样获得随机数和固定文本的概念,在$random3
中我只想显示由 $random
和 $random2
随机给出的整数之和,请帮助我。
最佳答案
您的 php 文件需要进行一些编辑。
<?php
$random= rand (1,5)."Boys";
$random2= rand (1,5)."Girls";
$random3=($random+$random2);
imagettftext($jpg_image, 25, 0, 10,20, $white, $font_path, $random);
imagettftext($jpg_image, 25, 0, 100,200, $white, $font_path, $random2);
imagettftext($jpg_image, 25, 0, 275, 50, $white, $font_path,$random3);
?>
现在一切正常了。我已经改正了。
关于php - php 中只能随机添加整数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29726074/