Javascript 如何使用请求变量包含到php文件
这是我的index.php:Javascript 如何使用请求变量包含到php文件,javascript,php,variables,Javascript,Php,Variables,这是我的index.php: <?php $num = 20; include("result.php"); if($result == 'OK') { echo 'The number is true'; } ?> 以及result.php: <?php if($_GET['num'] == 20) { $result = 'OK'; } else { $result = 'No'; } ?> 我怎么能做到?如何在本例中使用j
<?php
$num = 20;
include("result.php");
if($result == 'OK')
{
echo 'The number is true';
}
?>
以及result.php:
<?php
if($_GET['num'] == 20)
{
$result = 'OK';
}
else
{
$result = 'No';
}
?>
我怎么能做到?如何在本例中使用javascript
?
我对javascript一无所知。请为我找到解决此问题的方法。您可以像任何其他数组一样分配给
$\u get
:
$_GET['num'] = 20;
include("result.php");
但是,不建议这样做,因为现在$\u GET
不再实际表示请求的查询字符串参数。有什么原因不能在result.php
中直接使用$num
// If $num isn't set (by index.php), set it from the query string parameter
if ( ! isset( $num ) )
$num = $_GET['num'];
if($num == 20)
{
...
你的问题的标题和问题本身似乎自相矛盾;这是你想要的吗。我不明白我该做什么。