帮忙看一个函数,该怎么处理
帮忙看一个函数
- PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->function listlist(&$num) { //if(1==$page) $num_last=1; //else $num_last=$num-100+1; $file_name="data"; $real_num=0; for(;$real_num'; echo'<tr>'; echo'<td width="80%" style="font-size:13px;font-family=fantasy">'; //$message=fgets($fd_temp); echo $message[0]; echo"\n"; echo $i; echo'</td>'; echo'<td width="20%" style="font-size:13px;font-family=fantasy; text-align=center">'; echo"<a href="pre_delete.php?file=%24file_temp&num=%24i&max=%24max">删除留言</a>"; echo"</td>"; echo"</tr>"; //echo"<br>"; echo'<tr>'; echo'<td style="font-size:17px">'; for($i=1;$i"; echo"</td> </tr>"; echo''; } } $num--;}
这个函数是把php和html混杂在一起 ,对吗 行吗?
求高手赐教
------解决方案--------------------
个人觉得不能理解为“php和html混杂在一起”,php是服务器端的语言,服务器执行完之后,将结果吐回到到客户端显示~ 上面的代码只是拼接出一段html,直接在浏览器显示。吐回来的仅仅是一个结果,至于怎么用,完全取决于前端想怎么处理
------解决方案--------------------
所谓混杂是说代码混杂在一起,一般是不建议这么做的,楼主可以去参考一些模板的写法
代码乱以后不好维护.看一次蛋痛一次,这可不是痛一痛就习惯了
------解决方案--------------------
理论上是可以的,运行的结果就是一个table呀,但是最好不要这样,html和php分开
------解决方案--------------------
php处理的最终结果是要么输入到数据库或磁盘文件,要么输出到浏览器。
------解决方案--------------------
php和html代码混合在一起,这是常态,没什么不对的
虽然看上去不太舒服,修改起来一比较麻烦。但这是必须的,因为你需要在HTML中嵌入动态内容,而这些动态内容有需要用HTML标记包裹
当然你可以使用模板引擎将PHP代码和HTML代码分开,但最终执行的还是混合的代码。只是混合由模板引擎完成,而不是由你完成

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

React combines JSX and HTML to improve user experience. 1) JSX embeds HTML to make development more intuitive. 2) The virtual DOM mechanism optimizes performance and reduces DOM operations. 3) Component-based management UI to improve maintainability. 4) State management and event processing enhance interactivity.

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

PHP is suitable for web development, especially in rapid development and processing dynamic content, but is not good at data science and enterprise-level applications. Compared with Python, PHP has more advantages in web development, but is not as good as Python in the field of data science; compared with Java, PHP performs worse in enterprise-level applications, but is more flexible in web development; compared with JavaScript, PHP is more concise in back-end development, but is not as good as JavaScript in front-end development.
