Good practices to be known for php| development

Source: Internet
Author: User
Tags wrappers
<span id="Label3"></p>filtering, validating, Escaping<p><p>All these external resources are not fully trusted.</p></p> <ul> <ul> <li><p>$_get</p></li> <li><p>$_post</p></li> <li><p>$_request</p></li> <li><p>$_cookie</p></li> <li><p>$argv</p></li> <li><p>Php://stdin</p></li> <li><p>Php://input</p></li> <li><p>File_get_contents ()</p></li> <li><p>Remote Database</p></li> <li><p>Remote API</p></li> <li><p>Client-side data</p></li> </ul> </ul>Filter<p><p>Use <code>htmlentities()</code> filter HTML to convert special characters to HTML entities, escape output, and use the second parameter <code>ENT_QUOTES</code> .</p></p><p><p>Use <code>PDO预处理语句</code> filtered SQL Injection.</p></p><p><p>Use <code>filter_var()</code> <code>filter_input()</code> the & function to filter and validate different types of Input.</p></p> <blockquote> <blockquote> <p>eg:email, number, char, Special character</p> </blockquote> </blockquote>Password<p><p>The most secure hashing algorithm:<code>bcrypt</code></p></p><p><p>Use:</p></p><pre class="hljs bash"><pre class="hljs bash"><code>password_<span class="hljs-built_in">hash()password_get_info()password_needs_<span class="hljs-built_in">rehash()password_verify()</span></span></code></pre></pre><p><p>function to generate a Password.</p></p>date, time, TimeZone<p><p>Use the <code>DateTime</code> & & classes introduced by PHP5.2.0 <code>DateInterval</code> <code>DateTimeZone</code> to process Time.</p></p>Set the default time zone<p><p>In php.ini, set the</p></p><pre class="hljs coffeescript"><pre class="hljs coffeescript"><code><span class="hljs-string">‘country/city‘</span></code></pre></pre><p><p>Use the <code>date_default_timezone_set()</code> function to set the default time Zone.</p></p>DateTime Class<p><p>Use datetime classes to manage dates and times</p></p><pre class="hljs php"><pre class="hljs php"><code><span class="hljs-variable">$datetime = <span class="hljs-keyword">new DateTime();</span></span></code></pre></pre><p><p>Use <code>DateInterval</code> classes to construct fixed-length time PERIODS. Used in conjunction with methods in the previous class.</p></p>Datetimezone Class<p><p>The processing options for the time Zone.</p></p><pre class="hljs php"><pre class="hljs php"><code><span class="hljs-variable">$timezone = <span class="hljs-keyword">new DateTimeZone(<span class="hljs-string">‘Asia/Shanghai‘);<span class="hljs-variable">$datetime = <span class="hljs-keyword">new DateTime(<span class="hljs-string">‘2016-05-20‘, <span class="hljs-variable">$timezone);<span class="hljs-variable">$datetime->setTimezone(<span class="hljs-keyword">new DateTimeZone(<span class="hljs-string">‘Asia/Hong_Kong‘));</span></span></span></span></span></span></span></span></span></span></code></pre></pre>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.