Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/229.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
Javascript 如何使用请求变量包含到php文件_Javascript_Php_Variables - Fatal编程技术网

Javascript 如何使用请求变量包含到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

这是我的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';
}

?>

我怎么能做到?如何在本例中使用
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)
{
    ...

你的问题的标题和问题本身似乎自相矛盾;这是你想要的吗。我不明白我该做什么。