Home > Net >  PHP file not working on my chrome browser, or in my html files
PHP file not working on my chrome browser, or in my html files

Time:10-22

For my website, I am trying to embed stackoverflow.com and google.com, but it isn't working. So I started to work with PHP, but that didn't work. Does PHP work in html, or is it because I am using chromebook? Please help.

<iframe src="https://google.com" width="925" height="2400" frameborder="0" ></iframe><httpProtocol> <customHeaders> <add name="X-Frame-Options" value="*" /> </customHeaders> </httpProtocol><LocationMatch "/your_relative_path"> ProxyPass absolute_path_of_your_application/your_relative_path ProxyPassReverse absolute_path_of_your_application/your_relative_path </LocationMatch>

CodePudding user response:

You can't directly add most of the websites using iframe. PHP files can't run directly on a web browser like HTML files, you have to use a server like Xampp.

CodePudding user response:

Browsers only understand html, css (for markup and display) and javascript (for logic execution on the rendered (displayed) html view). Therefore, whichever framework you may use (like php) to serve any kind of content on browser, it should eventually send the content in html format to be displayed properly. (Other content types such as - image, video, file etc. are handled differently.)

For the iframe part, as others have stated in their answers, you cannot just embed any website on the internet in your own using the iframe tag. Browsers respect many response headers sent by websites, including the X-Frame-Options, which, if present in the website's response with deny as value, instructs any browser to disallow the content from that website to be served in an iframe. There are many other supported values for this header, and many other such headers have been standardized under Content security policy concept of the web.

So, it has most likely nothing to do with your Chromebook, if you're using the normal browsers.

CodePudding user response:

some website hoster don't want you to embed their sites into your own website. They can restrict this by setting X-Frame-Options. There is no way you can embed their sites using iframes.

And additionally: You can't run PHP directly in HTML. Please refer to the PHP Docs

  • Related