win 7下的php 第一天
(1)下载安装工具 wampServer
(2)排除obstacle,
先关闭iis
1)关闭iis服务 iisadmin
2)关闭iis下的虚拟主机实例,默认的网站(中间现实一个IIS的大jpg图像,指向iis.net),
win7下 “控制面板” - “管理工具” “IIS管理器” 删除应用即可。
如果使用端口查看器,会发现,80端口被系统所占用了,尽管进程选项中并没有出现iisadmin这一项,但是它被默认启动了,
被装入了windows的服务项,也就是说,只要你在iis上设置了这个虚拟目录,那么它就会在你登陆windows的时候把它装载进来,并且
占用了你的80端口,
使我的apache用不了(因为占用了80端口)
好了,现在我已经成功的进入了我的wampServer了。
真令人高兴啊。~~
http://localhost
http://localhost/phpmyadmin
创建了一个汽车商店的表单,提交给processorder.php处理,
显示处理的结果。
myphp.php
myphp.php<form action='processorder.php' method="post"><table align="center" border="0"><tr bgcolor="#cccccc"><td>Item</td><td>Quantity</td></tr><tr><td>Tires</td><td><input name='tireqty' type="textbox" size='3' maxlength="3"/></td></tr><tr><td>Oil</td><td><input name='oilqty' type="textbox" size='3' maxlength='3'/></td></tr><tr><td>Spark Plugs</td><td><input name='sparkqty' type="textbox" size='3' maxlength='3'/></td></tr><tr><td>How did you find Bob's?</td><td><select name="find"> <option value="a">I'm a regular customer</option> <option value="b">TV advertising</option> <option value="c">Phone directory</option> <option value="d">Word of mouth</option> </select></td></tr><tr><td colspan="2" align=center><input type="submit" value="submit Order" /> </td></tr></table></form>
processorder.php
processorder.php<html><head><title>simplyman's auto parts - order results</title></head><script type="text/css">.blue {color:blue};</script><body><h1 id="Bob-s-auto-parts">Bob's auto parts</h1><h2 id="Order-results">Order results</h2><?php echo '<p> Order processed at '. date('H:i, js F').'</p>'; //$tireqty; //$_POST[_'tireqty'] //$HTTP_POST_VARS[ 'tireqty'] $tireqty = $_POST['tireqty']; $oilqty = $_POST['oilqty']; $sparkqty = $_POST['sparkqty']; /* echo '<p>Your order is as follows :</p>'; echo $tireqty. ' tires<br />'; echo $oilqty. ' oils <br />'; echo $sparkqty.' sparks<br />'; */ //echo '$sparkqty sparks '; /* echo <<<theEnd line 1 line 2 line 3 theEnd */ $totalqty = 0; $totalqty =$tireqty +$oilqty +$sparkqty; if($tireqty <10){ $discount = 0; }elseif(($tireqty >= 10) && ($tireqty <= 49)){ $discount = 5; }elseif(($tireqty >= 50 )&&($tireqty <= 99)){ $discount = 10; }elseif($tireqty >=100){ $discount = 15 ; } if($totalqty == 0): echo '<p style=color:red>'; echo "You didn't order anything on the previous page! <br />"; echo '</p>'; exit; endif; /* if($totalqty == 0 ){ echo '<p style=color:red>'; echo "You didn't order anything on the previous page! <br />"; echo '</p>'; exit; } else { if($tireqty > 0 ) echo $tireqty. ' tires<br />'; if($oilqty >0) echo $oilqty. ' bottles of oils <br />'; if($sparkqty > 0) echo $sparkqty.' sparks<br />'; } */ $find=$_POST['find']; switch($find){ case 'a' : echo "<p class=blue>Regular customer.</p>"; break; case 'b': echo "<p class=blue>Customer referred by TV advert.</p>"; break; case "c": echo "<p class=blue>cusomer referred by phone directory</p>"; break; case "d": echo "<p class=blue>Customer referred by word of mouth.</p>"; break; default: echo "<p class=blue>we do not know how this costmer found us.</p>"; break; } echo "Item ordered :".$totalqty."<br />"; $totalamount = (float)$totalqty ; //$varname ='tireqty'; //$$varname= 5; $tireqty = 5'; define('TIREPRICE',100); define('OILPRICE',10); define('SPARKPRICE',4); //echo TIREPRICE.' tireprice<br />'; $totalamount =0.00 ; $totalamount = $tireqty * TIREPRICE + $oilqty * OILPRICE + $sparkqty * SPARKPRICE ; echo "Subtotal :$" .number_format($totalamount,2)."<br />"; $taxrate = 0.10 ;//local sales tax is 10% $totalamount = $totalamount * (1 + $taxrate); echo "Total including tax :".number_format($totalamount,2)."<br />"; $a = 56 ; echo gettype($a).'<br />'; settype($a,'double'); echo gettype($a)."<br />"; echo 'isset($tireqty,$oilqty,$sparkqty):'.isset($tireqty,$oilqty,$sparkqty).'<br />'; echo 'isset($nothere):'.isset($nothere).'<br />'; echo 'empty($tireqty):'.empty($tireqty).'<br />'; echo 'empty($nothere):'.empty($nothere).'<br />'; ?> <br /><br /><br /><br /> </body></html><?php // here is a comment ?> here is not <?php echo "<p> Order processed</p>" ?> <br /> <?php echo date('H:i, jS F'); phpinfo(); ?>

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

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

Dreamweaver CS6
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools

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

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
