PHP显示为HTML

时间:2013-10-31 13:55:54

标签: php html .htaccess wamp wampserver

这是我的代码

<?
include_once($_SERVER['DOCUMENT_ROOT'] . "/inc/path.php");

include $_SERVER['DOCUMENT_ROOT'] . "/inc/category_functions.php";

if (!$go4th) {
    die();
}

$content_links = content_links('tbl_content', 'content_id', 'title', '');

$content_id = 1; // home page content ID
$content = get_record('tbl_content', 'content_id', $content_id);
if ($content->show_title == 1) {
    $title = '<div class="content-title">' . $content->title . '</div>';
}

if ($content->page_title) { $page_title = $content->page_title; }
else if ($content->title) { $page_title = $content->title; }

if ($content->meta_keywords)    { $meta_keywords = $content->meta_keywords; } 
else                            { $meta_keywords = $META_KEYWORDS; }

if ($content->meta_description) { $meta_description = $content->meta_description; } 
else                            { $meta_description = $META_DESCRIPTION; }

// display the template
include $_SERVER['DOCUMENT_ROOT'] . "/inc/inside/email_list_popup.php"; //email list popup, first15 promo, etc
include $_SERVER['DOCUMENT_ROOT'] . "/template/" . $SITE_THEME . "/index.php";
?>

这是我在WAMP服务器上加载时显示的内容

  

show_title == 1){$ title ='   '。 $ content-&gt;标题。 “   “; } if($ content-&gt; page_title){$ page_title = $ content-&gt; page_title; } else if($ content-&gt; title){$ page_title = $ content-&gt; title; } if($ content-&gt; meta_keywords){$ meta_keywords = $ content-&gt; meta_keywords; } else {$ meta_keywords = $ META_KEYWORDS; } if($ content-&gt; meta_description){$ meta_description = $ content-&gt; meta_description; } else {$ meta_description = $ META_DESCRIPTION; } //显示模板包含$ _SERVER ['DOCUMENT_ROOT']。 “/inc/inside/email_list_popup.php”; //电子邮件列表弹出,first15促销等包括$ _SERVER ['DOCUMENT_ROOT']。 “/ template /”。 $ SITE_THEME。 “的index.php”; ?&GT;

就像它正在治疗&gt;在$ content-&gt;作为HTML的结束括号。

这是我的.htaccess

Options -MultiViews
RewriteEngine on
RewriteRule ^category/[0-9A-Za-z\-]+/c?([0-9]+)?m?([0-9]+)?p?([g0-9]+)?a?(1)?n?(1)?s?(1)?/?$ /category.php?category_id=$1&manufacturer_id=$2&page=$3&all=$4&new=$5&sale=$6
RewriteRule ^manufacturer/[0-9A-Za-z\-]+/([0-9]+)/?([0-9]+)?/?$ /category.php?manufacturer_id=$1&category_id=$2
RewriteRule ^item/[0-9A-Za-z\-]+/([0-9]+)/?p?-?([g0-9]+)?c?([0-9]+)?m?([0-9]+)?/?$ /item.php?item_id=$1&page=$2&category_id=$3&manufacturer_id=$4
RewriteRule ^content/[0-9A-Za-z\-]+/([0-9]+)/?$ /content.php?content_id=$1
RewriteRule ^sale/?$ /category.php?sale=1
RewriteRule ^new/?$ /category.php?new=1
RewriteRule ^all/?$ /category.php?all=1
RewriteRule ^all_manufacturers/?$ /category.php?all_mfg=1

<FilesMatch "\.(ttf|eot|svg|woff)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>

<IfModule mod_php5.c>
  AddType application/x-httpd-php .php .phtml .php3
  AddType application/x-httpd-php-source .phps
</IfModule>

1 个答案:

答案 0 :(得分:6)

看起来像是一个php-tag错误。

解决方案:

  • <?更改为<?php

  • 更改php.ini
  • 中的选项short_open_tag=On

希望有所帮助