PHP var 显示在 Chrome Dev Tool 中,但不显示在网页中

PHP var displays in Chrome Dev Tool, but not webpage

本文关键字:显示 网页 Dev var Chrome PHP Tool      更新时间:2023-09-26

我遇到了这个问题,我可以通过Chrome开发人员工具上的预览看到变量的回声,但在实际网页上它是空白的。

猜这是时间问题,所以要明确这一点,这就是我的方式。

  • 当页面(索引.php(加载时,它会链接一个.js文件,该文件在FB上执行FLQ查询以获取用户名。
  • 然后,它使用 ajax 将信息重新发布到索引.php。
  • 回到索引.php页面,它通过 $_POST 重新加载和收集
  • 然后,它显示一些以 $_POST 为单位的用户信息

我猜我为什么要这样做是不可能的,但奇怪的是,在 Chrome 开发工具中,所有变量都在页面上回显,但实际页面在变量应该显示的地方是空白的。

只能建议我有一个保留页面,收集详细信息,然后加载然后移动到主页以显示数据。

<!--
    Index.php
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head> 
    <?php
    global $uid;
    global $una;
    global $uem;
    global $uph;
    ?>
    <title></title>
    <script type="text/javascript"    src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script type="text/javascript" src="https://connect.facebook.net/en_US/all.js">   </script>
    <script type="text/javascript">
        // initialize the library with the API key
        FB.init({ apiKey: '2847xxxxxxxx689' });  
    </script>
    <?php
    ?>
    <script type="text/javascript">
        FB.login(function(response) {
            // handle the response
        }, {scope: 'email,publish_stream'});
    </script>
    <script type="text/javascript" src="jquery/op.js"></script>
 <?php
 $uid = $_POST['uid'];
 $una = $_POST['una'];
 $uem = $_POST['uem'];
 $uph = $_POST['uph'];
 echo $_POST['una'];
 ?>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" href="stylesheets/op_main.css" media="Screen" type="text/css"   />
  <?php
    //include('assets/opPHP.php');
    include('sql/ajaxsql.php');
    include('sql/phpsql.php');
    $opapp = new opapp;
    ?>
  <body>
    <div id="mainbody">
        <div id="topbanner">
            Beta Name <?php echo $una; ?>
        </div> 

 <--
  .js File
  -->
        $(window).load(function() {
            FB.api('/me', function(response) {
                var query = FB.Data.query('select uid,name,email, pic_square from user     where uid={0}', response.id);
                query.wait(function(rows) {
                    var uid = rows[0].uid;
                    var una = rows[0].name;
                    var uem = rows[0].email;
                    var uph = '<img src="' + rows[0].pic_square + '>';
                    $.ajax({
                        url: '../index.php',
                        type: 'POST',
                        data: 'uid=' + uid + '&una=' + una + '&uem=' + uem + '&uph=' + uph
                    });
                });
            });
        });

我可以看到它发布了信息,所以我的问题是。 是他们收集信息的另一种方式,同时在同一页面上。 甚至解释为什么我可以看到它开发工具,但看不到主页?

谢谢

安德鲁

echo $_POST['una'];会在

head 标签中回显,因此它会显示在 Chrome 开发工具中,但不会显示在网页中。

关于<?php echo $una; ?>,我没有看到任何地方设置了这个变量。所以这可能是它变得空白的原因