鍍金池/ 問答/ PHP問答
淡墨 回答

predis 這里已經(jīng)給了個demo了

自己封裝下,可以把下面的代碼加到 config/database.php,這樣就不用改動現(xiàn)在的代碼

'connections' => array(
        'tcp' => 'SimpleDebuggableConnection',
    ),
還吻 回答

$_GET是Http Get方法的參數(shù),它在命令行模式下不可用,因?yàn)樗枰獁eb server來填充。
如果你非要用的話,可以在腳本前面加上

// bash command:
//   export QUERY_STRING="var=value&arg=value" ; php -e myscript.php
parse_str($_SERVER['QUERY_STRING'], $_GET);
print_r($_GET);

或者不想改動腳本,這樣搞

php -e -r 'parse_str("id=1&type=2", $_GET); include "index.php";'

Stack Overflow傳送門

伴謊 回答

phpstorm + xdebug
xdebug 可以用斷點(diǎn)調(diào)試 也可以輸出日志分析 phpstorm有分析工具

心夠野 回答
  1. 假設(shè)你用QQ的10000申請接入和用10001接入的QQ互聯(lián),只要配置一下APP ID和APP KEY就可以切換管理員賬號了
  2. 如果你問的是為什么我用的是10000申請的QQ互聯(lián),別的QQ可以登錄,你需要了解oauth2的流程,QQ互聯(lián)也有接口文檔使用Authorization_Code獲取Access_Token

    1. 跳轉(zhuǎn)到QQ登錄頁面,其中攜帶回調(diào)地址
    2. 用戶登錄授權(quán)
    3. 登錄成功后,回調(diào)地址+授權(quán)碼Code
    4. 發(fā)送通過授權(quán)碼獲取access_token請求
    5. 使用access_token去獲取其它信息
玄鳥 回答

好混亂。。。

先把

    location ~ ^/index.php$ {
        root /usr/local/etc/nginx/;
        

中的 root這樣去掉。 配置中root指的是網(wǎng)站根目錄,你寫這個是啥

萌小萌 回答

已解決

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Demo extends CI_Controller {

    public function index() {
       $con=mysqli_connect("localhost","root","***","test"); 
       //輸出中文可以加一句 mysqli_query($con,"SET NAMES utf8");
       $query = mysqli_query($con,"select * from user");
       $array =  array();
       while($row = mysqli_fetch_assoc($query)){
        $array[] =  $row; 
      }
      echo json_encode($array);

    }
} 
壞脾滊 回答

session默認(rèn)配置文件讀寫。也可以設(shè)置存到memcache,redis。那么問題來了。一個用戶占多少個值,然后一個用戶大概需要占用到多少空間。如果同時(shí)在線人數(shù)不是很多,且session回收做好,其實(shí)用session來做是很合理的。

別硬撐 回答

一次子查詢即可

"SELECT DISTINCT p.prod_id, p.icon FROM product AS p
                  JOIN product_order AS po ON p.prod_id = po.prod_id
                  JOIN user_order AS uo ON 
                  po.order_id in (select order_id from PRODUCTTABLENAME) 
                  AND 
                  uo.id in (select user_id from PRODUCTTABLENAME)"

這樣一次查詢結(jié)果就出來了,然后遍歷輸出PRODUCTTABLENAME為你第一個循環(huán)查詢的表

小曖昧 回答

name 命名有問題。變量Role是什么?

蝶戀花 回答

Route::get('/setting/myinfo',['middleware'=>'login','HomeController@myinfo']);
改為:
Route::get('/setting/myinfo','HomeController@myinfo')->middleware('login');

以下是 5.5 創(chuàng)建路由的源碼:

protected function createRoute($methods, $uri, $action)
    {
        // If the route is routing to a controller we will parse the route action into
        // an acceptable array format before registering it and creating this route
        // instance itself. We need to build the Closure that will call this out.
        if ($this->actionReferencesController($action)) {
            $action = $this->convertToControllerAction($action);
        }

        $route = $this->newRoute(
            $methods, $this->prefix($uri), $action
        );

        // If we have groups that need to be merged, we will merge them now after this
        // route has already been created and is ready to go. After we're done with
        // the merge we will be ready to return the route back out to the caller.
        if ($this->hasGroupStack()) {
            $this->mergeGroupAttributesIntoRoute($route);
        }

        $this->addWhereClausesToRoute($route);

        return $route;
    }

以后貼報(bào)錯圖的時(shí)候,關(guān)鍵的堆棧信息要貼出來的,不然很難幫助到你。

淺淺 回答

有人說命令行執(zhí)行,不會受限,我需要定時(shí)執(zhí)行這個php,可行么?怎么做?

crontab

*/10 * * * * php /path/test.php   # 每10分鐘執(zhí)行一次

另外,你http請求等待120s,本身也不和邏輯啊,異步或者socket來做 。

初心 回答

提示的不是很清楚了吧, 現(xiàn)在memcached的根目錄下執(zhí)行 /usr/bin/phpize

phpize是什么?
phpize是用來擴(kuò)展php擴(kuò)展模塊的,通過phpize可以建立php的外掛模塊
比如你想在原來編譯好的php中加入memcached或者ImageMagick等擴(kuò)展模塊,可以使用phpize,通過以下幾步工作。

二、如何使用phpize?
當(dāng)php編譯完成后,php的bin目錄下會有phpize這個腳本文件。在編譯你要添加的擴(kuò)展模塊之前,執(zhí)行以下phpize就可以了;
比如現(xiàn)在想在php中加入memcache擴(kuò)展模塊:我們要做的只是如下幾步
復(fù)制代碼 代碼如下:

tar zxvf memcache-2.2.5.tgz
cd memcache-2.2.5/
/usr/local/webserver/php/bin/phpize
./configure –with-php-config=/usr/local/webserver/php/bin/php-config
make
make install
$date = explode('-','YYYY-MM-DD');
var_dump($date);

range

爆扎 回答

去看看它的源碼應(yīng)該會有所幫助

故人嘆 回答

打印…?還是顯示…?
如果用 console.log() 打印的話就跟 Vue 一點(diǎn)關(guān)系都沒有,就是單純的 js 遍歷。

function traverse(array) {
  array.forEach(item => {
    if (item.checked) {
      console.log(item.id)
    }
    if (item.children) {
      traverse(item.children)
    }
  })
}

traverse(data)
局外人 回答

1、如果你是在windows上操作,安裝xampp,把代碼部署進(jìn)去就可以了。

2、linux上則要安裝lnmp相關(guān)環(huán)境才可以。