當前位置:編程學習大全網 - 編程軟體 - 這句php代碼什麽意思 ?foreach( $wpcx_myposts as $post ) : setup_postdata($post); ?

這句php代碼什麽意思 ?foreach( $wpcx_myposts as $post ) : setup_postdata($post); ?

不可能就這部分,應該還有壹個endforeach;

foreach( $wpcx_myposts as $post ) : setup_postdata($post);

//中間代碼我不知道的哦

endforeach;

這是foreach的其他寫法

和:

foreach( $wpcx_myposts as $post ) {

setup_postdata($post);

}

壹致,沒有什麽特別的,只是多了壹個endforeach

也就是結束的意思,結束foreach循環

還有 if.... else if ..... else .... endif

for...endfor

while.....endwhile

這是為了照顧壹些從其他編程語言轉過來的童鞋們,所以有這個語法,沒什麽特別,foreach是循環。

$wpcx_myposts as $post 將 $wpcx_myposts 賦予 $post ,讓php自己去遍歷這個$wpcx_myposts 數組,然後調用 setup_postdata($post); 這個函數

  • 上一篇:寫了壹個發送端與接收端的ucp程序,為什麽運行有錯誤。怎麽解決?
  • 下一篇:bm3程序四合壹都是什麽
  • copyright 2024編程學習大全網