无法使用php代码保存HTML页面 [英] Can't save an HTML page with php code on it

查看:74
本文介绍了无法使用php代码保存HTML页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习PHP,当我尝试用PHP保存一个html页面时,表达式2告诉我不要这样做(或多或少表达式如何表达)。

这是图书示例

< title><?php //打印页面标题。
if(defined('TITLE')){//是否定义了标题?
print TITLE;
} else {//标题未定义。
打印'Elliott Smith粉丝俱乐部';
}
?> ;< / title>

点击保存为PHP的html页面后,表达式告诉我我不应该这样做然后我

< title>& lt;?php //打印页面标题。< / title>上面代码的位置。

我已经好几次了,我得到了相同的结果

现在我明白了,我应该可以保存一个包含php的html页面。

有没有人知道发生了什么?

感谢你们所有这一切都发生在我的电脑上,它不是通过服务器运行,它没有运行任何PHP,我所说的只是在添加php后单击保存为html文件

I'm learning PHP and when I try to save an html page with PHP on it, Expressions 2 tells me not to do it(thats more or less how Expressions puts it).

This is the book example

 <title><?php // Print the page title.
 if (defined('TITLE')) { // Is the title defined?
  print TITLE;
 } else { // The title is not defined.
  print 'Elliott Smith Fan Club';
 }
 ?></title>

After I click save for the html page with PHP on it an Expressions tells me I shouldn't do it and I then get

 <title>&lt;?php // Print the page title.</title>    where the above code was.

I 've done this several times and I've been getting the same results

Now as I understand it, I should be able to save an html page that contains php.

Does anyone have an idea whats going on?

Thanks
Steve

notes; all this happens on my computer, it is not running through a server, it is not running any PHP, all I'm talking about is clicking save for an html file after php is added

推荐答案

PHP页面需要保存为.php扩展名,以便通过PHP处理器处理页面。必须处理PHP,以便在将结果页面向下推送到浏览器之前执行PHP代码 - 因此服务器端代码。
PHP pages need to be saved as a .php extension so the page will be processed through the PHP processor.  PHP must be processed so the PHP code can be carried out before pushing the resulting page down the pipe to the browser - hence server-side code.


这篇关于无法使用php代码保存HTML页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆