数组中的php变量

 $q2=$_REQUEST['binge'];
'book2'=>array('callno'=>123006,'price'=>number_format(844,2),'desc'=>'Binge','auth'=>'Tyler Oakley','quant'=>$q2,'total'=>number_format(844,2)*$q2)

On this particular code, It kept displaying errors like this

Warning: A non-numeric value encountered in C:\xampp\htdocs\Webcard_3new\Webcard\wishlist.php on line 97

I searched all over the net for finding the right answers but some are just so complex to understand...

It supposed to be that $q2 is the variable inside an array. That variable is then multiplied to the "TOTAL". but the errors kept on going.. please help!!

You can use

$q2 = filter_var($_REQUEST['binge'], FILTER_VALIDATE_INT);

here you will have the benefit of validation where false is returned when someone passes a value that is not an integer. If it is instead a float use FILTER_VALIDATE_FLOAT instead.

Also, consider using $_GET, or $_POST directly to have more control of the data channel. $_REQUEST cobbles together several things into one, which sometimes may cause issues when more than one channel have the same key.

The super-globals will always be strings. You need to explicitly convert them using intval():

$q2 = intval($_REQUEST['binge']);

Also, this line:

'book2'=>array...

Should be

$book2 = array...