[英]echo value to a variable in PHP?
I want to have a PHP variable which value is generated by FBML. 我想要一个PHP变量,其值由FBML生成。
I can do that by go back and forth through AJAX. 我可以通过AJAX来回进行操作。
I wonder that it can be done purely in PHP. 我不知道这可以完全在PHP中完成。
This seems nonsense but what I want to do is like this. 这似乎是胡说八道,但我想做的就是这样。 Just to show my idea.
只是为了展示我的想法。
$value = echo "<fb:comments-count href=$url></fb:comments-count>";
Is there a way to make this work? 有没有办法使这项工作?
ob_start();
echo "<fb:comments-count href=$url></fb:comments-count>";
$value = ob_get_clean();
ob_end_clean();
But it is still pointless. 但这仍然没有意义。 As long as you can perform
echo
, you could perform variable assigning also. 只要您可以执行
echo
,就可以执行变量分配。
不,除了等待客户端对其进行解析,然后通过ajax将变量值发送回服务器之外,没有其他方法可以做。
Yes. 是。
ob_start();
echo $whatever;
$var = ob_get_clean();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.