有没有一种方法可以在回显变量中减去两个变量?

时间:2020-08-29 11:09:57

标签: php

我试图减去另一个变量中的两个变量,每次尝试时都会出现一个错误消息:“警告:遇到了非数字值”。我可以对变量进行乘法,加法,甚至除法,但是以某种方式减法会产生错误。下面是代码。

tf.compat.v1.disable_eager_execution()

print(tf.__version__)

x = model.input
y = model.output
grad = tf.gradients(y,x)[0]

sess = tf.compat.v1.Session()

result = sess.run(grad,feed_dict={x:train_images[0:1]})
print(result)

3 个答案:

答案 0 :(得分:3)

echo '<p>The answer is '. ($first - $second) .'</p> ';


//Output "The answer is -2"

答案 1 :(得分:3)

之前将两个值都减去一个变量。然后,您可以回显那个。

$first = 2;
$second = 4;
$result = $first - $second;

$answer.='<p>The answer is '.$result.'</p> ';
echo $answer;

或者,如果您想快速又脏乱地在计算中加上():

$answer.='<p>The answer is '.($first - $second).'</p> ';

答案 2 :(得分:2)

只需在计算中加上括号()

<?php
 $first = 2;
$second = 4;

$answer.='<p>The answer is '.($first - $second).'</p> ';
echo $answer;