Echo里面的元素属性? [英] Echo inside an element attribute?

查看:145
本文介绍了Echo里面的元素属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想知道是否可以在iframe中放置一个php echo?类似这样的事情:

I was just wondering if it is possible to put a php echo inside an iframe? something like this:

<iframe src="<?php echo $dyn; ?>" width="800" height="500" scrolling="yes"></iframe>

如果没有,这样做的正确方法是什么?

and if not, what is the correct way of doing this?

推荐答案

PHP的工作方式是,工作是在幕后完成,之前甚至被发送的HTML,所以在时间,你实际上是完整的数据发送到用户,它被解析为应该给浏览器的内容。

The way PHP works is that work is done behind the scenes, before the HTML is even sent, so by the time that you actually send the full data to the user, it's parsed into what should be given to the browser.

也就是说,例如

<?php
    $dyn = "index.html";
?>

<iframe src="<?php echo $dyn; ?>" width="800" height="500" scrolling="yes"></iframe>

当服务器全部关闭时,浏览器只会看到

By the time that the server breaks it all down, the browser will only ever see

<iframe src="index.html" width="800" height="500" scrolling="yes"></iframe>

这就是为什么你可以在同一页面上使用HTML和PHP,因为服务器在它之前解析PHP发送到浏览器,所以你最终只是发送文本/ HTML到最终位置。 Echo只是告诉PHP的手段,而不仅仅是这样做,向用户显示这个结果。,它围绕你已经存在的HTML构建它。

That's why you can use HTML and PHP on the same page, because the server parses the PHP before it's sent to the browser, so you end up just sending Text/HTML to the end location. Echo is simply the means of telling PHP, "Instead of just doing this, show the user this result.", and it builds it around the HTML you already have present.

这篇关于Echo里面的元素属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆