phpæ°ç¹æ§ä½ ç¥éå¤å°_php_web-itnose
é¦é¡µ
asp
php
javascript
iis
apache
html/css
coldfusion
ajax
vbscript
cgi
xml/xsl
è·¨æµè§å¨å¼å
ruby/rails
ç¨åºå
html5
jquery
seo
jboss
json
angularjs
markdown
nginx
thinkphp
yii
pageadmin
extjs
wampserver
kendo ui
coffeescript
gulp
ecmascript
bootstrap
itnoseé¦é¡µ > web > php >
phpæ°ç¹æ§ä½ ç¥éå¤å°
2017-06-12 09:31
1. ?? è¿ç®ç¬¦ï¼null å并è¿ç®ç¬¦ï¼ æè¿ä¸ªæ¾å¨ç¬¬ä¸ä¸ªè¯´æ¯å 为æè§å¾å®å¾æç¨ãç¨æ³ï¼ $a = $_get[‘a’] ?? 1;å®ç¸å½äºï¼ php$a = isset($_get[‘a’])
? $_get[‘a’] : 1; æ们ç¥éä¸å
è¿ç®ç¬¦æ¯å¯ä»¥è¿æ ·ç¨çï¼ $a ?: 1ä½æ¯è¿æ¯å»ºç«å¨ $a å·²ç»å®ä¹äºçåæä¸ã
1. ?? è¿ç®ç¬¦ï¼null å并è¿ç®ç¬¦ï¼
æè¿ä¸ªæ¾å¨ç¬¬ä¸ä¸ªè¯´æ¯å 为æè§å¾å®å¾æç¨ãç¨æ³ï¼
$a=$_get[‘a’]??1;
å®ç¸å½äºï¼
$a=isset($_get[‘a’])?$_get[‘a’]:1;
æ们ç¥éä¸å è¿ç®ç¬¦æ¯å¯ä»¥è¿æ ·ç¨çï¼
$a?:1
ä½æ¯è¿æ¯å»ºç«å¨ $a å·²ç»å®ä¹äºçåæä¸ãæ°å¢ç ?? è¿ç®ç¬¦å¯ä»¥ç®åå¤æã
2. å½æ°è¿åå¼ç±»å声æ
å®æ¹ææ¡£æä¾çä¾åï¼æ³¨æ…çè¾¹é¿åæ°è¯æ³å¨ php 5.6 以ä¸ççæ¬ä¸ææï¼ï¼
functionarrayssum(array…$arrays):array
{
returnarray_map(function(array$array):int{
returnarray_sum($array);
},$arrays);
}
print_r(arrayssum([1,2,3],[4,5,6],[7,8,9]));
ä»è¿ä¸ªä¾åä¸å¯ä»¥çåºç°å¨å½æ°ï¼å æ¬å¿åå½æ°ï¼é½å¯ä»¥æå®è¿åå¼çç±»åã
è¿ç§å£°æçåæ³æäºç±»ä¼¼äºswiftï¼
func sayhello(personname:string)->string{
let greeting=”hello, “+personname+”!”
returngreeting
}
è¿ä¸ªç¹æ§å¯ä»¥å¸®å©æ们é¿å ä¸äº php çéå¼ç±»å转æ¢å¸¦æ¥çé®é¢ãå¨å®ä¹ä¸ä¸ªå½æ°ä¹åå°±æ³å¥½é¢æçç»æå¯ä»¥é¿å ä¸äºä¸å¿ è¦çé误ã
ä¸è¿è¿éä¹æä¸ä¸ªç¹ç¹éè¦æ³¨æãphp 7 å¢å äºä¸ä¸ª declare æ令ï¼strict_typesï¼æ¢ä½¿ç¨ä¸¥æ ¼æ¨¡å¼ã
使ç¨è¿åå¼ç±»å声ææ¶ï¼å¦æ没æ声æä¸ºä¸¥æ ¼æ¨¡å¼ï¼å¦æè¿åå¼ä¸æ¯é¢æçç±»åï¼php è¿æ¯ä¼å¯¹å ¶è¿è¡å¼ºå¶ç±»å转æ¢ãä½æ¯å¦ææ¯ä¸¥æ ¼æ¨¡å¼ï¼ åä¼åºåä¸ä¸ªtypeerrorç fatal errorã
强å¶æ¨¡å¼ï¼
functionfoo($a):int
{
return$a;
}
foo(1.0);
以ä¸ä»£ç å¯ä»¥æ£å¸¸æ§è¡ï¼foo å½æ°è¿å int 1ï¼æ²¡æä»»ä½é误ã
ä¸¥æ ¼æ¨¡å¼ï¼
declare(strict_types=1);
functionfoo($a):int
{
return$a;
}
foo(1.0);
#phpfatalerror:uncaughttypeerror:returnvalue of foo()must be of the type integer,floatreturnedintest.php:6
å¨å£°æä¹åï¼å°±ä¼è§¦åè´å½é误ã
æ¯ä¸æ¯æç¹ç±»ä¼¼ä¸ js ç strict modeï¼
3. æ éç±»å声æ
php 7 ä¸çå½æ°çå½¢åç±»å声æå¯ä»¥æ¯æ éäºãå¨ php 5 ä¸åªè½æ¯ç±»åãæ¥å£ãarrayæè callable(php 5.4ï¼å³å¯ä»¥æ¯å½æ°ï¼å æ¬å¿åå½æ°)ï¼ç°å¨ä¹å¯ä»¥ä½¿ç¨stringãintãfloatåbooläºã
å®æ¹ç¤ºä¾ï¼
// coercive mode
functionsumofints(int…$ints)
{
returnarray_sum($ints);
}
var_dump(sumofints(2,’3′,4.1));
éè¦æ³¨æçæ¯ä¸ææå°çä¸¥æ ¼æ¨¡å¼çé®é¢å¨è¿éåæ ·éç¨ï¼å¼ºå¶æ¨¡å¼ï¼é»è®¤ï¼æ¢å¼ºå¶ç±»å转æ¢ï¼ä¸è¿æ¯ä¼å¯¹ä¸ç¬¦åé¢æçåæ°è¿è¡å¼ºå¶ç±»å转æ¢ï¼ä¸¥æ ¼æ¨¡å¼ä¸å触åtypeerrorçè´å½é误ã
4. use æ¹é声æ
php 7 ä¸ use å¯ä»¥å¨ä¸å¥è¯ä¸å£°æå¤ä¸ªç±»æå½æ°æ const äºï¼
usesome\namespace\{classa,classb,classcasc};
usefunctionsome\namespace\{fn_a,fn_b,fn_c};
useconstsome\namespace\{consta,constb,constc};
ä½è¿æ¯è¦ååºæ¯ä¸ªç±»æå½æ°æ const çå称ï¼å¹¶æ²¡æåpythonä¸æ ·çfrom some import *çæ¹æ³ï¼ã
éè¦çæçé®é¢æ¯ï¼å¦æä½ ä½¿ç¨çæ¯åºäº composer å psr-4 çæ¡æ¶ï¼è¿ç§åæ³æ¯å¦è½æåçå 载类æ件ï¼å ¶å®æ¯å¯ä»¥çï¼composer 注åçèªå¨å è½½æ¹æ³æ¯å¨ç±»è¢«è°ç¨çæ¶åæ ¹æ®ç±»çå½å空é´å»æ¥æ¾ä½ç½®ï¼è¿ç§åæ³å¯¹å ¶æ²¡æå½±åã
5. å ¶ä»çç¹æ§
å ¶ä»çä¸äºç¹æ§æå°±ä¸ä¸ä¸ä»ç»äºï¼æå ´è¶£å¯ä»¥æ¥çå®æ¹ææ¡£ï¼http://php.net/manual/en/migration70.new-features.php
ç®è¦è¯´å 个ï¼
php 5.3 å¼å§æäºå¿åå½æ°ï¼ç°å¨åæäºå¿åç±»äºï¼
define ç°å¨å¯ä»¥å®ä¹å¸¸éæ°ç»ï¼
éå ï¼closureï¼å¢å äºä¸ä¸ª call æ¹æ³ï¼
çæå¨ï¼æè å«è¿ä»£å¨æ´åéï¼å¯ä»¥æä¸ä¸ªæç»è¿åå¼ï¼returnï¼ï¼ä¹å¯ä»¥éè¿yield fromçæ°è¯æ³è¿å ¥ä¸ä¸ªå¦å¤ä¸ä¸ªçæå¨ä¸ï¼çæå¨å§æï¼ã
çæå¨ç两个æ°ç¹æ§ï¼return åyield fromï¼å¯ä»¥ç»åãå ·ä½ç表象大家å¯ä»¥èªè¡æµè¯ãphp 7 ç°å¨å·²ç»å° rc5 äºï¼æç»ççæ¬åºè¯¥ä¼å¾å¿«å°æ¥ã
äºèç½+æ¶ä»£ï¼æ¶å»è¦ä¿æå¦ä¹ ï¼æºæåéphp,dream it possibleã
æ´å¤phpç¸å ³ææ¯è¯·æç´¢åéphpï¼åçå®çèªå·±ï¼ç¨è¯å¿åæè²ãã
ç¸å
³æç´¢ï¼
html5æ°ç¹æ§
html5ç¹æ§
æ°å¾è¡¨è®¾è®¡
php jsp
php webservice
ç¸å ³æç«
2016-04-08 19:22 phpæ°ç¹æ§
2014-01-23 18:06 php 5.5 æ°ç¹æ§
2016-08-30 18:11 php7.1æ°ç¹æ§
2016-07-29 09:04 php7 æ°ç¹æ§
2015-06-24 13:52 php7æ°ç¹æ§ä»ç»
æ´å¤ç¸å ³æç« >>
ææ°æç«
2017-06-20 01:35 èé们ï¼æ没æå¯è½è®©phpæ件åæ¶åªè½ä¸ä¸ªäººè®¿é®
2017-06-20 01:35 æä¹ç¦æ¢å¾çç´æ¥éè¿url访é®
2017-06-20 01:35 æ±æ!å¯å¨wampåªè½ç¨æ¬æºè®¿é®,åå±åç½çå
¶å®è®¾å¤è®¿é®ä¸å°!æäºå¤§å天t-t
2017-06-19 15:35 nginxä¸çthinkphpé®é¢
2017-06-19 15:35 php form æ件ä¸ä¼
æ´å¤ææ°æç« >>
çé¨æç´¢
php å¾è¡¨
php xml
delphi for php
delphi php
php sqlserver
å建æ°çæ°æ®åº
oracle认è¯å¤å°é±
oracleå¹è®å¤å°é±
phpå.net
javaweb php
php asp.net
asp.net php
php webserviceæç¨
phpè°ç¨webservice
php è°ç¨ webservice
京icpå¤14022385å·-2
©2014 itnose软件ç¼ç¨æç¨ | èç³»æ们ï¼emailï¼twobrushes@126.com qq:35155868