user2964545
user2964545

Reputation: 3

How open iframe in php

<?php
    $url=$_GET['url'];
    $host = parse_url($url, PHP_URL_HOST);
    if ($host === 'example.com')
    { 
        //open $url in iframe
    } else {//code }
?>

How can I open a url in iframe in php,

Upvotes: 0

Views: 2915

Answers (2)

Ashkan Arefi
Ashkan Arefi

Reputation: 655

<?php
    $url=$_GET['url'];
    $host = parse_url($url, PHP_URL_HOST);
    if ($host === 'example.com')
    { 
        echo '<iframe src="'.$url.'" width="100%" height="100%"></iframe>';
    } 
?>

Upvotes: 0

lionheart98
lionheart98

Reputation: 968

You can add an iframe if the if condition is true:

<?php
    $url=$_GET['url'];
    $host = parse_url($url, PHP_URL_HOST);
    if ($host === 'example.com')
    { 
        //open $url in iframe
        ?>
        <iframe src="<?php echo $url; ?>"></iframe>
        <?php
    } else {//code }
?>

Upvotes: 2

Related Questions