-2

嘿,我如何在 PHP 中调用 iframe 或类似的东西?

我找到了一些代码,但我可能设置错误,这是我找到的代码,代码:

<iframe id="frame" src="load.php?sinput="<?php echo $_GET["sinput"]; ?> > </iframe>

有人知道任何 iframe PHP 代码或类似的 PHP 代码吗?

有人说不要使用 iframe,PHP 有什么?

4

1 回答 1

1

PHP 中没有生成 iframe 的函数。

你在做什么很好,但请允许我提出一个建议:

<?
    $input = "";
    if(isset($_GET['sinput'])) {
        $input = htmlspecialchars($_GET['sinput']);
    }
?>
<iframe id="frame" src="load.php?sinput="<?php echo $input; ?>">Your browser does not support iframes</iframe>

编辑:实际上

<?
    $url = "load.php";

    // Query Building Logic
    $querys = array();
    if(isset($_GET['sinput'])) {
        $queries[] = "sinput=".htmlspecialchars($_GET['sinput']);
    }

    // Generate full URL
    if(count($queries) > 0) {
        $url .= "?" . implode("&", $queries);
    }
?>
<iframe id="frame" src="<? echo $url; ?>">Your browser does not support iframes</iframe>

我认为整体质量更好,但我的同龄人无法判断。这只是另一个建议,在完整的逻辑块中生成完整的可用 URL 以在 HTML 中使用,而不是依赖于模板中存在和可用的信息(因为如果数组中的元素由于['sinput']任何$_GET原因未设置,该页面将直接吸引您。

于 2013-07-14T23:28:03.657 回答