贴上代码:
<span>php </span><span>error_reporting</span>(<span>E_ALL</span> & ~<span>E_NOTICE</span><span>); </span><span>$expression</span>=<span>$_GET</span>['TrueTable']; <span>//</span><span>读取输入框数据</span> <span>if</span>(!<span>empty</span>(<span>$_GET</span>['TrueTable'<span>])){ </span><span>$expression</span>=<span>strtoupper</span>(<span>$expression</span>); <span>//</span><span>将输入的小写字母,替代成大写字母</span> <span>$expressionArr</span>=<span>str_split</span>(<span>$expression</span>); <span>//</span><span>将$expression转换成数组</span> <span>foreach</span>(<span>$expressionArr</span> <span>as</span> <span>$v</span>){ <span>//</span><span>把字母放在 $varTotal数组中</span> <span>if</span>(<span>$v</span>>='A' && <span>$v</span>){ <span>$varTotal</span>[]=<span>$v</span><span>; } } </span><span>$varTotal</span> = <span>array_unique</span>(<span>$varTotal</span>); <span>//</span><span>去掉$varTotal数组中重复的字母</span> <span>sort</span>(<span>$varTotal</span>); <span>//</span><span>$varTotal数组中字母正向排序</span> <span>$varTotal1</span> = <span>preg_replace</span>("/([A-Z])/","$\\1",<span>$varTotal</span>); <span>//</span><span>$varTotal1数组中字母变成变量</span> <span>$maxN</span> = <span>count</span>(<span>$varTotal</span><span>); </span><span>//</span><span>$expressionArr = preg_replace("/([A-Z])/","$\\1",$expressionArr); //$expressionArr数组中字母变成变量</span> <span>$newExpression</span>=<span>implode</span>('',<span>$expressionArr</span>); <span>//</span><span>$expressionArr数组变成字符串 //echo $newExpression."<br>";</span> <span>$newExpression</span>= <span>preg_replace</span>("/([A-Z])->([A-Z])/","!\\1|\\2",<span>$newExpression</span><span>); </span><span>$newExpression</span>= <span>preg_replace</span>("/(\(.*?\))->([A-Z])/","!\\1|\\2",<span>$newExpression</span><span>); </span><span>$newExpression</span>= <span>preg_replace</span>("/(\(.*?\))->(.*?)/","!\\1|\\2",<span>$newExpression</span><span>); </span><span>$newExpression</span>= <span>preg_replace</span>("/([A-Z])->(.*?)/","!\\1|\\2",<span>$newExpression</span><span>); </span><span>$expressionArr</span>=<span>str_split</span>(<span>$newExpression</span>); <span>//</span><span>将$expression转换成数组</span> <span>$expressionArr</span> = <span>preg_replace</span>("/([A-Z])/","$\\1",<span>$expressionArr</span><span>); </span><span>$newExpression</span>=<span>implode</span>('',<span>$expressionArr</span><span>); </span><span>//</span><span>echo $newExpression;</span> <span> } </span>?> <meta charset="utf-8"> <title>真值表查询1.0 BY:小臻</title> <span><h1 id="真值表查询-BY-小臻">真值表查询1.0 BY:小臻</h1></span> <div> <form action="" method="get"> <input type="text" name="TrueTable" value="<?php echo <span>$_GET</span>['TrueTable'] ?>"> <input type="submit" value="确定"> <br> <br> <!--<input type="reset" value="取消" /><br /><br /> <input type="button" value="∨" /> <input type="button" value="∧" /> <input type="button" value="┐" /> <input type="button" value="→" /> <input type="button" value="↔" /><br /><br />--> </form> <!--[ 说明:析取(∨) , 合取(∧) , 非(┐) , 蕴含(→) , 等价(↔) ]--> <p>[ 说明:析取(|) , 合取(&) , 非(!) , 蕴含(->) , 等价(=) ]</p> <table width="300px"> <span>php </span><span>echo</span> "<tr>"<span>; </span><span>if</span>(!<span>empty</span>(<span>$_GET</span>['TrueTable'<span>])){ </span><span>foreach</span>(<span>$varTotal</span> <span>as</span> <span>$v</span><span>){ </span><span>echo</span> "<td>{<span>$v</span>}</td>"<span>; } </span><span>echo</span> "<td>结果</td>"<span>; </span><span>$result</span>=<span>pow</span>(2,<span>$maxN</span><span>); </span><span>for</span>(<span>$i</span>=0;<span>$i</span>$result;<span>$i</span>++<span>){ </span><span>$resultN</span>[<span>$i</span>]=<span>sprintf</span>("%0{<span>$maxN</span>}d",<span>decbin</span>(<span>$i</span><span>)); </span><span>$resultN</span>[<span>$i</span>]=<span>str_split</span>(<span>$resultN</span>[<span>$i</span><span>]); } </span><span>foreach</span>(<span>$resultN</span> <span>as</span> <span>$k</span>=><span>$v</span><span>){ </span><span>echo</span> "</tr> <tr>"<span>; </span><span>foreach</span>(<span>$resultN</span>[<span>$k</span>] <span>as</span> <span>$k1</span>=><span>$v1</span><span>){ </span><span>echo</span> "<td>".<span>$v1</span>."</td>"<span>; </span><span>$varTotal2</span>[<span>$k1</span>]=<span>$varTotal1</span>[<span>$k1</span>]."=".<span>$v1</span><span>; </span><span>//</span><span>echo $varTotal2[$k1]." ";</span> <span>eval</span>(<span>$varTotal2</span>[<span>$k1</span>].";"<span>); } </span><span>//</span><span>echo $newExpression;</span> <span>eval</span>("\$varTotal3[] = ".<span>$newExpression</span>.";"<span>); </span><span>foreach</span>(<span>$varTotal3</span> <span>as</span> <span>$k2</span>=><span>$v</span><span>){ </span><span>if</span>(<span>$v</span>==<span>NULL</span><span>){ </span><span>$varTotal3</span>[<span>$k2</span>]=0<span>; } } </span><span>echo</span> "<td>".<span>$varTotal3</span>[<span>$k</span>]."</td>"<span>; </span><span>echo</span> "</tr>"<span>; } </span><span>//</span><span>print_r($varTotal3);</span> <span> } </span>?> </table> </div>
以上就介绍了php版的求表达式的真值表-TrueValueTable,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

ThesecrettokeepingaPHP-poweredwebsiterunningsmoothlyunderheavyloadinvolvesseveralkeystrategies:1)ImplementopcodecachingwithOPcachetoreducescriptexecutiontime,2)UsedatabasequerycachingwithRedistolessendatabaseload,3)LeverageCDNslikeCloudflareforservin

You should care about DependencyInjection(DI) because it makes your code clearer and easier to maintain. 1) DI makes it more modular by decoupling classes, 2) improves the convenience of testing and code flexibility, 3) Use DI containers to manage complex dependencies, but pay attention to performance impact and circular dependencies, 4) The best practice is to rely on abstract interfaces to achieve loose coupling.

Yes,optimizingaPHPapplicationispossibleandessential.1)ImplementcachingusingAPCutoreducedatabaseload.2)Optimizedatabaseswithindexing,efficientqueries,andconnectionpooling.3)Enhancecodewithbuilt-infunctions,avoidingglobalvariables,andusingopcodecaching

ThekeystrategiestosignificantlyboostPHPapplicationperformanceare:1)UseopcodecachinglikeOPcachetoreduceexecutiontime,2)Optimizedatabaseinteractionswithpreparedstatementsandproperindexing,3)ConfigurewebserverslikeNginxwithPHP-FPMforbetterperformance,4)

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


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

Atom editor mac version download
The most popular open source editor

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

Dreamweaver Mac version
Visual web development tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.
