Jump to content

Recommended Posts

Okay, I know this is a simple problem with a solution but I don't know what it is.

I have an html file, in the file I am trying to execute php tags like;

<?php <i>the php tags</i> ?>

When executed in the browser the html is rendered but the php tags are not.  If I do a 'view source' on the page, the literal text of the php tag is there but it doesn't execute?

-TIA
Link to comment
https://forums.phpfreaks.com/topic/29012-silly-problem/
Share on other sites

if the page is a ' .php ' it will execute php just fine - a '.html' page will execute html fine.  A .php page wil render html fine.

The issue is being able to include php tags inside of a .html file via <?php ?>

I am using apache 2.2.3

[code]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<title>Planitlanit</title>

</head>

<body>

test

<?php require('navibar.html'); ?>

testt

</body>

</html>

[/code]

When I execute the above .html file, everything renders BUT the '<?php ?>' part.  I can see the literal "<?php require('navibar.html'); ?>" when I view source and that is it.
Link to comment
https://forums.phpfreaks.com/topic/29012-silly-problem/#findComment-132923
Share on other sites

It seems there is some confusion of how server-side scripting works. Just because a file has php code in it means nothing. The server must first be configured to process PHP code - then the server must be told what file to process as PHP. When a user requests a page from the server, the server will check the list of file types that it is supposed to process. If the file is not in the list, then it simply delivers the file as-is to the browser. If the file is in the list of files to be processed, it sends it to the appropriate interpreter (PHP, ASP, etc.) and acts on any code within the file. The "output" of this processing is then delivered to the browser - not the file.

In fact, you can set your server to process files with the .asp extension as PHP. That will really confuse people!
Link to comment
https://forums.phpfreaks.com/topic/29012-silly-problem/#findComment-132983
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.