鍍金池/ 問答/ PHP問答
孤毒 回答

因?yàn)?code>$_SERVER['REQUEST_METHOD'] != 'POST'

問題已經(jīng)解決,寫出答案方便后來的新手查看。
1.dd打印出來的代碼,仔細(xì)查看是可以看到有數(shù)據(jù)傳過來的。在控制器里echo可以直接顯示出來數(shù)據(jù)。
2.拿到數(shù)據(jù)后,直接使用構(gòu)造查詢器update更新,$res = DB:table('xxx')->where('id',$id)->update(['oid'=>$oid]);

伐木累 回答

是配置那邊寫錯了,在一個配置文件里前面log配置了socket ,后面log又配置成了file ,相當(dāng)于后面的log配置重置了前面的配置, 關(guān)于socket配置那個是沒有問題的

蝶戀花 回答

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)錯圖的時候,關(guān)鍵的堆棧信息要貼出來的,不然很難幫助到你。

過客 回答

ConvertEmptyStringsToNull 中間件是 Laravel 5.4 才開始加入的。

By default, Laravel includes the TrimStrings and ConvertEmptyStringsToNull middleware in your application's global middleware stack. These middleware are listed in the stack by the AppHttpKernel class. These middleware will automatically trim all incoming string fields on the request, as well as convert any empty string fields to null. This allows you to not have to worry about these normalization concerns in your routes and controllers.
If you would like to disable this behavior, you may remove the two middleware from your application's middleware stack by removing them from the $middleware property of your AppHttpKernel class.

看官方描述的意思就是為了規(guī)范化數(shù)據(jù)。

如果你確實(shí)不想這樣處理,可以在 app/Http/Kernel.php 文件中注釋掉此 middleware

    /**
     * The application's global HTTP middleware stack.
     *
     * These middleware are run during every request to your application.
     *
     * @var array
     */
    protected $middleware = [
        \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
        \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
        \App\Http\Middleware\TrimStrings::class,
        \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, //注釋掉此行
    ];

或者:

從數(shù)據(jù)庫層面,把 remark 字段的默認(rèn)值設(shè)置為 空字符串

吃藕丑 回答

把xdebug那里的9000改為9001,9000應(yīng)該被你本機(jī)php-fpm默認(rèn)使用了

青瓷 回答

對的,我修改了代碼,注釋忘改了

淡墨 回答

localhost:800還是localhost:8000呢?
還有我不太理解為什么把第二個的secure設(shè)為true,從代碼上來看,你只是鏈接到了http的接口呀

溫衫 回答

就是類似于sf這種投票、反對的功能吧?如果是我來做的話,我會這樣搞:

id     article_id user_id   is_like
自增ID   文章ID     用戶ID    是否喜歡(1喜歡0不喜歡)

如上是表的數(shù)據(jù)結(jié)構(gòu),應(yīng)該符合你的功能需求;
而且取值、查詢也方便;

laravel中如何操作不清楚,但是如果你的欄位非要存1,2,3,4,5這種數(shù)據(jù)結(jié)構(gòu)的話,那么原生的mysql可以采用find_in_set函數(shù)來操作;

做不到 回答

lnmp 環(huán)境的nginx 默認(rèn)開啟了30天的緩存,你把nginx虛擬主機(jī)配置發(fā)出來(/usr/local/nginx/conf/vhosts/目錄下)

六扇門 回答

找到問題了 在 location ~ .php$ {下的root也要改成/usr/local/nginx/html/ci/

擱淺 回答

原因:浮點(diǎn)數(shù)的精度問題。

轉(zhuǎn)為整型

clipboard.png

注意:

  1. 向下取整,即:12910.9 會被轉(zhuǎn)換為 12910

    <?php
    var_dump(intval(12910.9));
    
    // 輸出
    // int(12910)
  2. 浮點(diǎn)數(shù)精度
    clipboard.png

    看如下執(zhí)行結(jié)果:
    clipboard.png
    我們知道:$receive_money 值小于 12911

總結(jié):所以,最后 $receive_money 轉(zhuǎn)換為整型時,向下取整,結(jié)果為:12910

參考:


問題補(bǔ)充:

為什么 float(12911) 沒有顯示成 12910.9999... 呢?

這是由于浮點(diǎn)數(shù)的二進(jìn)制表示形式?jīng)Q定的。
看如下示例:

clipboard.png

我們看到第 9 行代碼 float(12911) 擴(kuò)展整數(shù)位之后,轉(zhuǎn)換成整型表示:int(129109999)
然后,我們對比了 float(12911)int(12911) 在二進(jìn)制上的差別。
是不是發(fā)現(xiàn)了什么?(二進(jìn)制的最后一位)這是 PHP-bug 么?當(dāng)然不是。
而且我們同樣也注意到了第 8 行代碼輸出結(jié)果為:float(129110000),這又是為什么呢?
為什么不是 float(129109999)呢?

我們看一下 PHP 源碼中浮點(diǎn)數(shù)是什么:
clipboard.png
如圖:php-float 等于 c-double
我想如下幾個問題可以解決上述的疑問:
雙精度浮點(diǎn)數(shù) 的二進(jìn)制形式是如何表示的呢? 請參考:wikipedia-雙精度浮點(diǎn)數(shù)
浮點(diǎn)數(shù)是如何處理乘法運(yùn)算的呢? 請參考:wikipedia-浮點(diǎn)數(shù)的乘法和除法

如果上邊兩個問題不愿深究,可以直接參考鳥哥的一篇博客:PHP浮點(diǎn)數(shù)的一個常見問題的解答

以上為個人理解,如果錯誤之處,請指出。

糖豆豆 回答

首先,問問題貼代碼
其次,你判斷條件用的什么?file?

疚幼 回答

現(xiàn)在的問題是你phpmyadmin用的是xampp環(huán)境的mysql,navicat用的是自己安裝的。想要一致我覺得最好的辦法就是停用掉xammp的mysql,然后把phpmyadmin的鏈接指向你自己安裝的mysql;

萌二代 回答

.+?問好緊跟著.+,意思就是前面的.+組合(任意字符)可有可無。

近義詞 回答

clipboard.png

onHeaderCell和onHeaderRow用法一致

瞄小懶 回答

查看你的 /etc/hosts 文件 看看有沒有
127.0.0.1 localhost
這樣的映射