Jump to content

[PHP, HTML, Apache (XAMP)] Inline PHP Tags Do Not Get Processed


glassfish

Recommended Posts

<body>

<?php

Echo "Hello World!";

 

?>

<h1> The headline here</h1>

</body>

 

The above os an example.

The problem can be read in title.

When clicking on View Source Code in the web browser the PHP tags are still there, which means they have not gotten processed.

Why does this happen?

Using Apache (XAMP).

Link to comment
Share on other sites

that is something to do with xampp configuration i guess

 

Make sure your file has the .php extension on it, otherwise it will not be executed as PHP.

 

Make sure that the PHP module is listed and uncommented inside of your Apache's httpd.conf This should be something like LoadModule php5_module "c:/php/php5apache2_2.dll" in the file. Search for LoadModule php, and make sure that there is no comment (;) in front of it.
 
Make sure that the http.conf file has the PHP MIME type in it. This should be something like AddType application/x-httpd-php .php. This tells Apache to run .php files as PHP. Search for AddType, and then make sure there is an entry for PHP, and that it is uncommented.
Link to comment
Share on other sites

XAMPP comes with everything preconfigured so there should not be any issues with running your PHP code.

 

I think the problem is you have loaded your .php file directly into the browser (ie the address bar starts with file://) This is not how you run your PHP files.

 

You need to first check you have saved your php files in XAMPP's htdocs folder (I assume for windows its C:/XAMPP/htdocs ) now run your php files by accessing http://localhost/yourfile.php

Link to comment
Share on other sites

I have tried it when using an HTML file. Are there issues when doing this?

 

As I said, PHP Tags do not work if file extension is *.html or *.htm

For php tags to get parsed, the file must be in *.php extension.

as @Ch0cu3r said, it must be in a folder in htdocs folder and try opening it in broswer as localhost/<folder_name>

Link to comment
Share on other sites

As I said, PHP Tags do not work if file extension is *.html or *.htm

For php tags to get parsed, the file must be in *.php extension.

That's not true. You can tell apache to parse any file extension as php, but Apache has to be set up that way using the AddType directive.

Link to comment
Share on other sites

Here is a video showing it:

https://www.youtube.com/watch?v=qRaz1CRMGEg

 

Again, the processing of the PHP tags do not happen to myself (with this topic).

What? You saying the code used in that video does not work for you? Instead you see the PHP code?

 

Can you tells us

  • Where are you saving the php files to
  • How are you accessing the php files in your browser?
  • Ensured XAMPP is running
Link to comment
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.