Json_Encode +包括/要求 +弹性+ PHP 语言?
我希望我的 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 应用程序上?
谢谢我真的很感谢你的帮助!
I want my Wordpress user to login and I can put their username as a $variable in Header.php then use json_encode in (json_tutorial.php) to call it onto my flex app, Json_tutorial.mxml
this is my short version of ... 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
?>
the files Json_tutorial.mxml and Json_tutorial.php are from http://sadhas.wordpress.com/2009/11/26/flex-php-transmitting-data-using-json/#wrapper
I want to know why this doesn't work with the Include or Require?
Also how I can call the variable from header.php to json_tutorial.php to be json_encode onto my flex app?
Thank I really appreciate the help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我遇到了同样的问题,我通过在 echo json_encode(...) 之前使用 ob_clean() 解决了它。
I had the same problem and I solved it by using ob_clean() just before echo json_encode(...).