简体   繁体   English

PHP页面上的内容类型HTML

[英]Content type HTML on PHP Page

I found a Webpage saved as something.php . 我发现一个网页另存为something.php But the source code tells me <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 但是源代码告诉我<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

I also found out that PHP code does not work on the webpage. 我还发现PHP代码在网页上不起作用。 What is the need for making the file extension PHP if HTML is used? 如果使用HTML,对文件扩展名PHP有什么要求? (Not exactly HTML, but XHTML) (不完全是HTML,而是XHTML)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

What is the need for making the file extension PHP if HTML is used? 如果使用HTML,对文件扩展名PHP有什么要求? (Not exactly HTML, but XHTML) (不完全是HTML,而是XHTML)

Considering your comments so far, particularly you stated there is no PHP; 考虑到您到目前为止的评论,特别是您声明没有PHP。 you can just change the file extension to XHTML. 您可以将文件扩展名更改为XHTML。 You can always change it back. 您可以随时将其改回。

I wonder what other PHP files exists where you "found" this page and why. 我想知道您在哪里“找到”了该页面的其他PHP文件以及原因。 Assuming someone before you developed the site, there is probably a reason they used PHP file extensions. 假设有人在您开发站点之前,可能是他们使用PHP文件扩展名的原因。

Unless your host doesn't support PHP, then you should be able to run php code anywhere on that page by placing it inside "" tags. 除非您的主机不支持PHP,否则您应该可以将其放在“”标记内,从而可以在该页面上的任何位置运行php代码。 The 'Content-type' isn't relevant to whether PHP can run or not. “内容类型”与PHP是否可以运行无关。 Try adding the following code somewhere in your page: 尝试在页面的某处添加以下代码:

<?php echo "Hey there, I'm a friendly PHP string!"; ?>

add this <?php echo "Hello!"; ?> 添加此<?php echo "Hello!"; ?> <?php echo "Hello!"; ?> in your page to test, and make sure that your server is running, and normally it works <?php echo "Hello!"; ?>在页面中进行测试,并确保服务器正在运行,并且正常运行

Are you using a wamp/mamp server? 您是否正在使用沼泽/沼泽服务器? Have you tried to turn it on? 您是否尝试将其打开?

These code are meta tags 这些代码是元标记

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

and it has nothing to do with php unless you have included a php script to it. 除非您包含了php脚本,否则它与php无关。

Html/XHtml will run even though you are not using a php server. 即使您没有使用php服务器,Html / XHtml也将运行。 All php files has a .php file extension and will run only if you use a server like wamp for windows or mamp for mac. 所有的php文件都有一个.php文件扩展名,并且仅当您使用Windows的wamp或Mac的mamp等服务器时才可以运行。

You can still use html/xhtml code in a .php file. 您仍然可以在.php文件中使用html / xhtml代码。

For example I have an <h1>This is h1</h1> tag and you want to make it dynamic, you can put <?php ?> inside the tag and echo it out to display, <h1><?php echo "This is h1"; ?></h1> 例如,我有一个<h1>This is h1</h1>标记,您想使其动态化,您可以将<?php ?>放入标记中,并将其回显以显示, <h1><?php echo "This is h1"; ?></h1> <h1><?php echo "This is h1"; ?></h1> . <h1><?php echo "This is h1"; ?></h1>

In case you want to put html code inside a php script, you can do it like this 如果您想将html代码放入php脚本中,则可以这样做

<?php echo "<h1>This is h1</h1>"; ?>

You can learn more about php and other programming languages by the help of google. 您可以在Google的帮助下了解有关php和其他编程语言的更多信息。 Just take your time, relax and enjoy learning. 慢慢来,放松并享受学习。 Don't pressure yourself, remember learning is not a medicine that when you take it, it will work in a few minutes. 不要给自己施加压力,请记住学习并不是一种医学,它可以在几分钟内起作用。 Learning takes time and practice. 学习需要时间和实践。 Enjoy coding. 享受编码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM