


Summary of commonly used special operation symbols and functions in PHP (a must-read for newbies to PHP)_PHP Tutorial
注解符号:
// 单行注解
多行注解
引号的使用
' ' 单引号,简单字符串,不经任何处理直接拿过来;
" "双引号,php动态处理然后输出,一般用于处理$变量.
布尔变量:
一种是true 即 真的;
另一种是false 即假的
常见变量:
string 字串(数字\汉字\等等)
integer 整数(1、2、3、4、5、0、-1、-2、等等)
double 浮点数(小数点)
array 数组
object 对象
可以用的方法有gettype($mix) 和settype($mix,$typename);
常用符号转义:
" " Double quotes
" \ Backslash
n n Line feed
r Return to the beginning of the line
t Horizontal tabulation
Arithmetic symbols:
+ Addition operation -Rugging operations *multiplication operation /division of the method
%remains ++ self -plus 1
-self -reduction 1. Connect two string
assignment operation:
/= Divide the value on the left by the value on the right
.= Add the string on the right to the left
Bitwise operations:
^ Bitwise exclusive OR (xor) != is not equal to && and || or ! Other operation symbols other than
$ Variable symbol
Alias for variable
@ Do not display error message (added before function)
-> Object method or attribute
=> The element value of the array
?: Ternary operator
Commonly used basic methods:
1. PHP converts strings to upper and lower case!
strtolower(); Convert characters to lowercase
strtoupper(); Convert characters to uppercase
2.PHP encrypted string
Irreducible:
md5();
sha1();
Reducible:
base64_encode();
base64_decode();
3. About quotation marks
1. Single quotes are output as is
2. Double quotes are content interpretation and output
3. Anti-single quotes (small quotes) are used to execute a system command, such as `dir`. Commonly used in table names and field names.
4. "" acts on translation characters, such as "n" for newline.
4. Functions: htmlspecialchars() and htmlentities()
This function converts special characters into HTML string format ( &....; ). The most commonly used occasion may be the message board for processing customer messages.
& (and) is converted to &
" (double quotes) is converted to "
> (greater than) is converted to >
(space ) into
5. Batch output HTML content!
echo HTML output content. . . //Comments here are still output!
EOT;
print HTML output content. . . //Comments here are still output!
EOT;
(Note: Use "{variable}" for internally included variables)
6. Determine whether the file exists and output the content file_exists ()
$FileName="File.TXT";
if (file_exists($FileName)){
echo "
".file_get_contents($FileName)."< ;/pre>";<br>}else<br>{<br>echo "no";<br>}<br>?> <p>7. Delete variables to release memory unset();</p> <p>unset($var);<br>unset($var,$var1);</p> <p>8.is_numeric;<br>Detect whether the variable is a number; </p> <p>9.is_int;<br>Detect whether the variable is an integer;</p> <p>10.is_null;<br>Detect whether the variable is NULL;</p> <p>11.is_string<br>Detect whether the variable is a string</p> <p>12.is_real;<br>alias of is_float()</p> <p>13.isset<br>Check whether the variable is defined</p> <p>14.is_bool<br>Detect whether the variable is of Boolean type</p> <p>15.is_array<br>Detect whether the variable is an array</p> <p>16.is_object<br>Detect whether the variable is an object</p> <p>17.substr() function returns a part of the string. </p> <p>substr (String,Start,SelectNum)<br></p><div class="codetitle"> <span style="CURSOR: pointer" onclick="doCopy('code86858')"><u>Copy code</u></span> The code is as follows:</div><div class="codebody" id="code86858"> <br>echo substr('abcdef', 1); // bcdef<br>echo substr('abcdef', 1, 3); // bcd<br>echo substr('abcdef', 0, 4); // abcd<br>echo substr('abcdef ', 0, 8); // abcdef<br>echo substr('abcdef', -1, 1); // f<br> </div> <p>18.nb2br() Convert the escaped newline into html<br><br></p><div class="codetitle"> <span style="CURSOR: pointer" onclick="doCopy('code78572')"><u>Copy code</u></span> The code is as follows:</div><div class="codebody" id="code78572"> <br>echo nl2br("foo isn'tn bar");<br> </div> <p align="left"></p><div style="display:none;"> <span id="url" itemprop="url">http://www.bkjia.com/PHPjc/326498.html</span><span id="indexUrl" itemprop="indexUrl">www.bkjia.com</span><span id="isOriginal" itemprop="isOriginal">true</span><span id="isBasedOnUrl" itemprop="isBasedOnUrl">http: //www.bkjia.com/PHPjc/326498.html</span><span id="genre" itemprop="genre">TechArticle</span><span id="description" itemprop="description">Annotation symbols: // Use of single-line annotation and multi-line annotation quotation marks ' ' Single quotation mark, simple string, without Take any processing directly; " "Double quotes, php dynamic processing and then output, generally used for processing...</span> </div> <div class="art_confoot"></div>

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl

TomakePHPapplicationsfaster,followthesesteps:1)UseOpcodeCachinglikeOPcachetostoreprecompiledscriptbytecode.2)MinimizeDatabaseQueriesbyusingquerycachingandefficientindexing.3)LeveragePHP7 Featuresforbettercodeefficiency.4)ImplementCachingStrategiessuc

ToimprovePHPapplicationspeed,followthesesteps:1)EnableopcodecachingwithAPCutoreducescriptexecutiontime.2)ImplementdatabasequerycachingusingPDOtominimizedatabasehits.3)UseHTTP/2tomultiplexrequestsandreduceconnectionoverhead.4)Limitsessionusagebyclosin

Dependency injection (DI) significantly improves the testability of PHP code by explicitly transitive dependencies. 1) DI decoupling classes and specific implementations make testing and maintenance more flexible. 2) Among the three types, the constructor injects explicit expression dependencies to keep the state consistent. 3) Use DI containers to manage complex dependencies to improve code quality and development efficiency.

DatabasequeryoptimizationinPHPinvolvesseveralstrategiestoenhanceperformance.1)Selectonlynecessarycolumnstoreducedatatransfer.2)Useindexingtospeedupdataretrieval.3)Implementquerycachingtostoreresultsoffrequentqueries.4)Utilizepreparedstatementsforeffi


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

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool
