鍍金池/ 問答/ PHP問答
挽歌 回答

ok,解決了。一個小錯誤

別逞強 回答

你作為調(diào)用方,是不知道對方接口有哪些數(shù)據(jù)有變更的,若要做到只拿更新的數(shù)據(jù),可以提供一個思路:
接口提供方再提供一個接口,返回有變更的id列表給到你,之后接收方只根據(jù)最新的list進行獲取

忠妾 回答

你從后端把這個值渲染到前臺模板,輸出就可以啦

心夠野 回答

不是PHP的問題. 是Java的事.

你這兒應(yīng)該使用的是 form 方式上傳的. 這是application/x-www-form-urlencoded格式.
你的&沒轉(zhuǎn)義, 在服務(wù)器商肯定接收不到正確數(shù)據(jù).

你可以直接上傳json格式字符串, 在PHP里用file_get_contents('php://input') 取值. 然后解析.

熊出沒 回答

前端切,而且不需要你自己弄,常見的上傳控件都自帶分片上傳,你只需要管php的文件合并就可以了,不過為什么要用sftp上傳呢?

厭遇 回答

1.現(xiàn)在config目錄添加一個global.php全局配置文件;
2.在global.phpreturn 一個數(shù)組 :

return [
    'test' =>env('TEST','這是測試配置'),
];

3.上面配置可在 .env文件中修改,保證項目靈活性;

TEST=這是測試test的配置

4.使用 : config('global.test');

安若晴 回答

樓主,這個問題怎么解決?我現(xiàn)在卡在這一步了。

荒城 回答

PHP支持mbstring.func_overload, 用于解決原生substr無法有效應(yīng)對多字節(jié)編碼字符串問題

mbstring
支持一個“函數(shù)重載”功能,將對應(yīng)的多字節(jié)版本重載到標準字符處理函數(shù)上,例如你能夠讓這類應(yīng)用在不修改代碼的前提下添加多字節(jié)的處理能力。
比如,啟用函數(shù)重載后,mb_substr() 將會代替 substr() 被調(diào)用。
在很多情況下這個功能允許讓僅支持單字節(jié)編碼的應(yīng)用簡單地和多字節(jié)環(huán)境對接。

要使用函數(shù)重載功能,設(shè)置 php.ini 里的 mbstring.func_overload 為正值,就是表示為重載函數(shù)分類的位掩碼組合。
要重載 mail() 函數(shù)需要設(shè)置它為 1。字符串函數(shù)設(shè)置為 2,正則表達式函數(shù)為 4。 例如,當它設(shè)置為 7, mail、strings和 正則表達式函數(shù)將都會被重載。

那么這種情況下php runtime狀態(tài)是未知的, 所以在計算字符長度時, 用mb_strlen 8bit來保證計算字符串長度的正確性(按照1byte = 8bit)

久不遇 回答

1 <?php
2 $newword = "
3 直達:通往
4 小:大
5 ";
6 $str_txt = "這是一條直達美好殿堂的小道。";
7 $pairs = preg_split("/[:".PHP_EOL."]/", trim($newword));
8 $i = 0;
9 while($i < count($pairs)) {
10 list($ori[], $tar[]) = [$pairs[$i++], $pairs[$i++]];
11 }
12 var_dump(str_replace($ori, $tar, $str_txt));
輸出:
string(42) "這是一條通往美好殿堂的大道。"
str_replace是支持批量替換的。

喵小咪 回答

// 這個是小年糕公司的筆試題, 我做了這個題目獲得了面試資格.去公司面試也是筆試,筆試掛掉了。
// 然后到公司是做這3個題目,https://www.cnblogs.com/mingz...

// 不考慮字母
function s2i(s) {
    return s.split('').reduce(function(a, c) {
        var code = c.charCodeAt(0);
        if (48<=code && code < 58) {
            a.push(code-48);
        }
        return a;
    }, []).reduce(function(a, c) {
        return 10*a + c;
    }, 0);
}
 
function versionCmp(s1, s2) {
    var a = s1.split('.').map(function(s) {
        return s2i(s);
    });
    var b = s2.split('.').map(function(s) {
        return s2i(s);
    });
    var n = a.length < b.length ? a.length : b.length;
    for (var i = 0; i < n; i++) {
        if (a[i] < b[i]) {
            return -1;
        } else if (a[i] > b[i]) {
            return 1;
        }
    }
    if (a.length < b.length) return -1;
    if (a.length > b.length) return 1;
    var last1 = s1.charCodeAt(s1.length-1) | 0x20,
        last2 = s2.charCodeAt(s2.length-1) | 0x20;
    return last1 > last2 ? 1 : last1 < last2 ? -1 : 0;
}
菊外人 回答

第一種:

php.ini里邊

date.timezone="Asia/Shanghai"

第二種:

文件開始加入:

date_default_timezone_set('Asia/Shanghai');
愛礙唉 回答

RewriteRule ^(.*)$ index.php/$1 [QSA,NU,PT,L]

在偽靜態(tài)規(guī)則后面加上 [QSA,NU,PT,L] 配置完成

終相守 回答

你可以使用更高層面的$resource服務(wù)來進行上傳,參考官方文檔

冷眸 回答

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>

  1. 在httpd.conf配置文件搜索 LoadModule rewrite_module modules/mod_rewrite.so
  2. AllowOverride None 將None改為 All
孤島 回答

用PHP 預(yù)定義常量DIRECTORY_SEPARATOR來代替'','/'這樣的路徑分隔符

過客 回答

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ù)。

如果你確實不想這樣處理,可以在 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 字段的默認值設(shè)置為 空字符串

孤毒 回答

postman 里 Content-Type 是 application/x-www-form-urlencoded, Body 為 from-data 的話會在 $_POST 里
Content-Type 是 application/json, Body 為 raw (JSON) 用 file_get_contents("php://input") 接收

也就是 為啥在 input 里的原因吧