php拾遺_PHP教程
教程Tag:暫無(wú)Tag,歡迎添加,賺取U幣!
推薦:php會(huì)話機(jī)制總結(jié)1 什么是會(huì)話 web中的會(huì)話實(shí)際上是指瀏覽器和web服務(wù)器之間的會(huì)話,形象一點(diǎn):就好比兩個(gè)人進(jìn)行一段對(duì)話。 2 php會(huì)話機(jī)制工作原理 當(dāng)瀏覽器向服務(wù)器發(fā)送URL請(qǐng)求,服務(wù)器會(huì)生成一個(gè)會(huì)話ID,并將瀏覽器端的一些信息保存在服務(wù)器端,然后將會(huì)話ID送到瀏覽器端保存到cookie
在for循環(huán)中的extract時(shí),如果數(shù)組的下標(biāo)不包含到$buy等后續(xù)要使用的變量,會(huì)導(dǎo)致使用其他不相關(guān)的或者前一次生成的變量,需要特別的注意
- //計(jì)算庫(kù)存
- foreach($aGoodsLst as $goodsid => $aGoods)
- {
- $aGoods['price'] = $aGoods['buy']==0?0:($aGoods['buymoney']/ $aGoods['buy']);
- $aGoods['stock'] = $aGoods['buy'] - $aGoods['sell'] + $aGoods['return'];
- $aGoods['stockmoney'] = $aGoods['stock'] * $aGoods['price']; //庫(kù)存金額以進(jìn)價(jià)為準(zhǔn)
- //重新計(jì)算銷售金額
- $aGoods['sell'] = $aGoods['sell'] - $aGoods['return'];
- $aGoods['sellmoney'] = $aGoods['sellmoney'] - $aGoods['returnmoney'];
- //盈余
- $aGoods['earn'] = $aGoods['sellmoney']-$aGoods['buymoney'];
- extract($aGoods);
- $sSql = "UPDATE goods SET buy='$buy',buymoney='$buymoney',stock='$stock',stockmoney='$stockmoney',sell='$sell',sellmoney='$sellmoney',`return`='$return',returnmoney='$returnmoney',earn='$earn' WHERE id=$goodsid";
- $oDb->query($sSql);
- }
分享:php中瀏覽器關(guān)閉后,能繼續(xù)執(zhí)行的函數(shù)希望關(guān)閉瀏覽器后,程序能繼續(xù)在后臺(tái)跑,這種情況下需要用到ignore_user_abort()函數(shù); 多的不說(shuō),直接上代碼: ignore_user_abort(true); //設(shè)置客戶端斷開(kāi)連接時(shí)是否中斷腳本的執(zhí)行 set_time_limit(0); $file = '/tmp/ignore_user.txt' ; if (! file_exists ( $file )
相關(guān)PHP教程:
- PHPNOW安裝Memcached擴(kuò)展方法詳解
- php記錄頁(yè)面代碼執(zhí)行時(shí)間
- PHP中獎(jiǎng)概率的抽獎(jiǎng)算法程序代碼
- apache設(shè)置靜態(tài)文件緩存方法介紹
- php對(duì)圖像的各種處理函數(shù)代碼小結(jié)
- PHP 關(guān)于訪問(wèn)控制的和運(yùn)算符優(yōu)先級(jí)介紹
- 關(guān)于PHP語(yǔ)言構(gòu)造器介紹
- php/js獲取客戶端mac地址的實(shí)現(xiàn)代碼
- php5.5新數(shù)組函數(shù)array_column使用
- PHP preg_match的匹配多國(guó)語(yǔ)言的技巧
- php 中序列化和json使用介紹
- php采集文章中的圖片獲取替換到本地
- 相關(guān)鏈接:
- 教程說(shuō)明:
PHP教程-php拾遺
。