webman開啟 'support_php_files' => true,
其中index.php中如下
test.php中如下
瀏覽器訪問index.php 多次刷新 有時(shí)這樣
多刷幾次后變量$var就沒有了
index.php改成require終端會(huì)報(bào)
這個(gè)為何$var變量再require_once以后多刷新幾次就沒有了?
workerman是常駐內(nèi)存的。require_once 只會(huì)加載一次,第二次不會(huì)加載,所有沒有$var。 如果是每次require,test函數(shù)就會(huì)被重復(fù)定義。 解決辦法:函數(shù)或者類定義用require_once加載,業(yè)務(wù)代碼用require 或者 include
好的謝謝!