Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/246.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/89.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
HTML与PHP不起作用_Php_Html_Apache - Fatal编程技术网

HTML与PHP不起作用

HTML与PHP不起作用,php,html,apache,Php,Html,Apache,我使用Apache作为服务器, 我的index.php代码是 <?php session_start(); ?> <html> <my HTML code> <?php wait_file:{ // Do something to receive file. } else { goto wait_file; } } detect_file:{ if(file_exists($fil

我使用Apache作为服务器, 我的index.php代码是

<?php session_start(); ?>
<html>
<my HTML code>
<?php
wait_file:{
        // Do something to receive file.
    }
    else
    {
        goto wait_file;
    }
}

detect_file:{
    if(file_exists($file))
    {
        // do something with received file.
    }
    else
    {
        goto detect_file;
    }
}
?>
</html>
但是当我访问index.php时, 网页总是在加载, 我的背景图片没有显示这可能意味着HTML代码不起作用, 我想关键是我使用了goto,使if循环等待文件, 但我不知道怎么解决它

在这段代码中,实际上没有太多可以工作的东西。我不 知道$file可能来自何处,它看起来没有定义,所以 您的转到将导致无限循环。 那么你必须有一个if才能使用else。 由于无限循环,因此没有输出,因此加载时为空。我甚至看不到页面应该显示什么,因为我不知道后面是什么。您发布的代码中没有输出。
什么意思?具体点。我不知道你是否真的理解了你的问题如果总是加载你的意思是它不会停止加载,那么你的PHP代码就是你的问题而不是HTML。我的index.PHP是空的,我猜我的HTML代码不起作用。你知道怎么解决吗?我需要PHP部分,我不能让页面空白:我将PHP部分设置为等待循环,等待我从另一个设备发送的文件,我已经对它进行了测试,它做得很好。但当我添加HTML时,它仍然只是等待,不显示我的背景、标题等等。我需要这两种代码,我如何通过HTML显示我的外观并同时等待文件?只有一张背景照片,以及HTML代码中下一页的按钮。您正在混合服务器端代码和客户端代码。PHP在服务器上运行,一旦完成,HTML将发送到客户端。您可以使用Javascript中带有setInterval的AJAX请求检查文件。您的意思是我必须使用AJAX接收文件,因为它是异步的,所以我可以避免无限循环?没错。另一种方式是,在文件可用之前,您不会收到任何内容。