我使用下面的方式,想在不同的<?php?>標(biāo)簽內(nèi)共用變量,但是實(shí)現(xiàn)不了,我也試過(guò)$_SESSION,也不可以做到。<form method="get">
<input type="text" name="num1" placeholder="num1">
<input type="text" name="num2" placeholder="num2">
<button type="submit" name="submit" value="func1">提交</button></form>The result is: <?phpif (isset($GLOBALS['result'])) { echo "111"; echo $GLOBALS['result'];
}?><?php$GLOBALS['result'] = 0;if(isset($_GET['submit']) && $_GET['submit'] == 'func1'){
$num1 = $_GET['num1'];
$num2 = $_GET['num2'];
$GLOBALS['result'] = $num1 + $num2;
}?>
怎么實(shí)現(xiàn)一個(gè)頁(yè)面多個(gè)PHP標(biāo)簽內(nèi)共用變量?
慕的地6264312
2018-08-18 19:38:48