MKM
MKM

Reputation: 33

Echoing an iframe based on logic in php

I am in a nasty situation. I am trying to echo an iframe in php based on an if statement. However this returns a blank space.

I think this is due to the wrong escaping [single/double quotation] but can't figure it out :(

My code:

echo '<iframe src="'.$the_iframe_calling_url.'" frameborder="0"></iframe>';

any luck on this?

Okay, here is my code with if block. I am stuck with this :(

//check if this is image or not
    if (($file_type === 'image/gif')or($file_type === 'image/jpeg')or($file_type === 'image/jpg')or($file_type === 'image/pjpeg')or($file_type === 'image/x-png')or($file_type === 'image/png') ){
        echo '<img src="'.$final_file_url.'" width="70%" />';
        }

    else{

    $the_iframe_calling_url = 'https://docs.google.com/viewer?url='.$final_file_url; //http url

    //echo $final_file_url;
    echo '<iframe src="'.$the_iframe_calling_url.'" frameborder="0"></iframe>';


    echo $the_iframe_calling_url;
        }
    }

Upvotes: 0

Views: 83

Answers (1)

Jorge Campos
Jorge Campos

Reputation: 23361

There is nothing wrong with your code. Maybe the url your are trying to open is the problem. $the_iframe_calling_url

Or the if statement that was said in the comment

Since you posted the URL you are trying to show in an Iframe here is your answer:

Iframe google problem

Upvotes: 2

Related Questions