【发布时间】:2012-02-29 15:04:55
【问题描述】:
我希望我的 Wordpress 用户登录,我可以将他们的用户名作为 $variable 放在 Header.php 中,然后使用 (json_tutorial.php) 中的 json_encode 将其调用到我的 flex 应用程序 Json_tutorial.mxml
这是我的简短版本... json_tutorial.php
<?php
require_once ('header.php'); //works without this, but doesn't work with this
$surname = '$variable'; // $variable = 'doe'; from header.php
$p = array ('first_name' => john, 'last_name' => $surname);
echo json_encode($p); // prints out john doe
?>
文件 Json_tutorial.mxml 和 Json_tutorial.php 来自http://sadhas.wordpress.com/2009/11/26/flex-php-transmitting-data-using-json/#wrapper
我想知道为什么这不适用于 Include 或 Require?
另外,我如何将 header.php 到 json_tutorial.php 的变量调用为 json_encode 到我的 flex 应用程序上?
非常感谢我的帮助!
【问题讨论】:
-
该代码示例在多个层面上都存在错误,很难判断这只是复制/粘贴问题还是您的问题。请定义“不起作用”。你的例子(有点)说它确实有效。
-
是的,我不应该有 $variable 的引号...我编辑它。似乎一旦我有“REQUIRE_ONCE”或使用“INCLUDE”,它就不会出现在我的 flex 上。这里附上两张截图:dnykitchen.com/demo/wp-content/themes/imbalance2/…dnykitchen.com/demo/wp-content/themes/imbalance2/…
-
也许它只是因为包含的文件中的某些内容而死掉,或者有其他输出搞砸了最终输出? “使用
include,在Flex 中看不到数据”回答起来有点粗略,您必须在那里一步一步调试。 -
即使我在 Include/Require 中什么都没有 - 它的中断。要求一次();有没有办法解决这个问题?
-
启用错误报告,检查错误日志,调试脚本以查看失败的原因。
require_once不会关闭输出,只是不会。
标签: php apache-flex include mxml json