English 中文(简体)
一起使用 HTML & Php 吗? [已关闭]
原标题:Using HTML & Php together? [closed]
最佳回答

你可以把两者结合起来

PHP(和任何其他服务器辅助技术)是用来生成 HTML 内容并在服务器上处理,然后将输出返回客户端的网络浏览器。

我“强势”Scrongly

1 - 你可以把它们和PHP的回声声明结合起来:

 <?php 
 echo "<html>";
 echo "<title>HTML with PHP</title>";
 echo "<b>My Example</b>";

 //your php code here
 // Or you can use the print command

 print "<i>Print works too!</i>"; 
 ?> 

还有另一种方法,例如:

2. 在HTML内嵌入 PHP 代码

 <html> 
 <title>HTML with PHP</title>
 <body>
 <h1>My Example</h1>

 <?php
 //your php code here
 ?>

 <b>Here is some more HTML</b>

 <?php
 //more php code
 ?>


 </body>
 </html>

但是,相信我这一点,你会更清楚地知道,当我提到你学习PHP时,你将会更清楚地知道发生了什么。此外,互联网上有一些资源可以开始学习PHP。 (Google是你的朋友! )

祝你好运!

问题回答

PHP 通常用于生成 HTML, 因此您可以在通常使用 HTML 的任何地方使用 HTML 。 您可以随意( 在合理范围内) 将代码拼凑成任意的代码, 它应该工作正常 。

我建议让另一位学生来帮助你。 如果他们创建了PHP, 他们可能比你更了解网站的创建。

  • Host your site on a server which uses Apache webserver so as your PHP pages will be compiled on server-side.
  • Rename all your .html pages to .php pages in which you want to include some php logic.
  • Embed your PHP code inside <?php and ?> tags inside your PHP pages.
  • Use separate PHP files for connection, functions etc.
  • If your re confused, then you ll find this basic tutorial on PHP helpful.

仅设计 HTML 中的页面并将其重新命名为php。 做任何您想要的 php 函数

<?php

?>

此嵌套外的脚本将显示为 html 。 如果您想要在 内显示任何内容, 请使用 >>>> , print printf

您可以查看

One of the things I don t see mentioned here is a templating engine, which are actually quite handy when it comes to seperating PHP from HTML.
I use Smarty myself. The good thing about templating engines is that you can really seperate the templates (HTML) from PHP. So the designer hardly needs to know any PHP functions, and the PHP programmer only needs to worry about functionality and not design.
The PHP programmer (using smarty in this case) assigns the values to be displayed to the smarty template and then the designer just includes these variables in his normal HTML. Works like a charm if you ask me and doesnt really require lots of code changes if done right (not sure in this case).

"http://www.smarty.net/" rel="nofollow" >Smarty Tylating 引擎

PHP 的起始路径, I think the best path is < a href=""http://www.w3schools.com/php/default.asp" rel="nofollow" >http://www.w3schools.com/php/default.asp , 如果您想要添加学生的页面比, 请检查页面的静态或动态性, 如果页面是静态的( 完全 HTML) 而不是您需要做的任何事情, 只要将这些页面保存为.php 扩展, 如果有动态页面( 与数据库连接), 而不是您对基本php 的知识。





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签