NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Identical files displaying differently in localhost


Joined: 21 Aug 2014
Posts: 2
Reply with quote
My first post to this forum, not sure if right place, please let me know if different.

After recent phpED upgrade to 14309 64 bit personal edition, I have strange problem. Not related to upgrade? I don't know.

I have web page, index.html that uses php function to get consistent look across site, using open_page() type function. It works just as I wish.

I create an IDENTICAL web page index.html in a new project, set up identical to the first, and localhost does not parse php code, it just displays it??

If I save this page as index.php, it displays fine, just as the original page in the original project did AND STILL DOES as index.html.

Any change in settings, mistakes, etc should affect both projects, would they not?

Any help in what to look for would be greatly appreciated, I have gone over and over and over and not seeing anything different in the code.

Server set up XAMPP Apache if makes any difference. Don't think server is issue, but just don't know at this point.

The code, if it will help is:

<?php

include_once("info/class_page.inc");
include_once("info/define.inc");

$newPage = new page( );

$index = 1;

$title = "Title";
$author = "Author";
$keyWords = "Keywords";
$description = "Description";
$heading = "Heading";
$newPage->open_page( $index, $title, $author, $keyWords, $description, $heading );
?>

<p>Text begins here</p>

End of Code here ----------------

But, looking a little closer, the output of the index.html on the local host begins at open_page->

Looking in the source code, all of the php code is there where it should not be????
View user's profileFind all posts by willgb54Send private message
Guru master

Joined: 24 Jul 2009
Posts: 737
Reply with quote
I don't fully understand the problem at the moment, but a few comments to get started:

html pages do not normally execute PHP on the web server. Whilst you can change the web server to execute PHP in html files (eg in site .htaccess), best practices normally indicate you should not.

If for any reason your web server does not execute the PHP in the html file, it will instead send the source code to the browser and that could be considered a security risk. So you probably should really use index.php and not index.html and for the site that does execute PHP in the html file, maybe review the site settings and turn that off. It is possible that one of your sites is set to execute PHP in html files and the other site is not?

If the page does not disable caching, you will have to force reloads on the page to see changes and that might be confusing. Whilst html meta can be used to partially disable caching, it is better to use http headers to disable caching. You can disable caching using either Apache web server settings (eg server level or in site .htaccess) or PHP code (just ask if you would like some code).

Also, to clarify something on the html side of things; if you use Apache rewrites you can have a URL that ends in .html but in reality that file does not exist and the rewrite will instead use a PHP file to process the URL and send output. Many frameworks use rewrites to send all URL's for non-existent files through index.php
View user's profileFind all posts by plugnplaySend private message


Joined: 21 Aug 2014
Posts: 2
Reply with quote
Still not sure what happened.

Thanks for the response, plugnplay.

Just switched to index.php as you said and is working.
View user's profileFind all posts by willgb54Send private message


Joined: 22 Apr 2014
Posts: 17
Reply with quote
willgb54 wrote:
Still not sure what happened.

Switching to the .php extension surely is the better option. If you want to understand why it works in one project and not in the other one, search for a file named .htaccess in the root of the project where it works (or in a directory above that) and look out for one of the following lines (or both):

Code:
AddType application/x-httpd-php .html
AddHandler application/x-httpd-php .html

This can also be defined in the Apache configuration. Do you work with different vhosts ("local domains")? Then it's probably defined in X:\xampp\apache\conf\extra\httpd-vhosts.conf (replace X with the letter of the drive where XAMPP is installed).

Cheers,
Jan
View user's profileFind all posts by JCISend private message
Identical files displaying differently in localhost
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic