簡體   English   中英

strpos() 和 preg_split() 警告

[英]strpos() and preg_split() warning

我的其中一個頁面上有 2 個警告問題……如果您能幫助我,我將不勝感激。

警告:strpos() 期望參數 1 是字符串

警告:preg_split() 期望參數 2 為字符串

這是我的代碼:

if ( strpos($term, '+') !== false ) {
                $terms = preg_split( '/[+]+/', $term );
                if (is_array($terms) || is_object($terms)) {
                foreach ( $terms as $term ) {
                    $tax_query[] = array_merge( $tax_query_defaults, array(
                        'terms' => array( $term )
                    ) );
                } }
            } else {
                $tax_query[] = array_merge( $tax_query_defaults, array(
                    'terms' => preg_split( '/[,]+/', $term )
                ) );
            }

嘗試:

if (is_string($term) && strlen($term) && strpos($term, '+') !== false ) {

在你的第一行

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM