Home > php教程 > PHP源码 > body text

良好的php代码

PHP中文网
Release: 2016-05-25 17:13:57
Original
945 people have browsed it

优良的PHP代码应该是结构化的。

优良的PHP代码应该是规范化的。

优良的PHP代码应该是自适应的。

优良的PHP代码应该是安全的。

1. [代码]PHP代码的优劣体现在哪里?    

1.未优化过的php代码
<?
echo(”<p>Search results for query: ” .
    $_GET[&#39;query&#39;] . “.</p>”);
?>
2.简单优化过的代码
<?
echo(”<p>Search results for query: ” .
    htmlspecialchars($_GET[&#39;query&#39;]) . “.</p>”);
?>
3.合理优化过的代码
<?php  
if (isset($_GET[&#39;query&#39;]))   
{   
  echo ‘<p>Search results for query: ‘,   
      htmlspecialchars($_GET[&#39;query&#39;], ENT_QUOTES), ‘.</p>’;   
}   
?>
Copy after login

                   

                   

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template