Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/253.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在php中,只能从random中添加整数_Php - Fatal编程技术网

在php中,只能从random中添加整数

在php中,只能从random中添加整数,php,Php,我正在用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

我正在用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);
?>

现在它可以正常工作了。我已经改正了