sanitize_mime_type

函式
sanitize_mime_type ( $mime_type )
引數
  • (string) $mime_type Mime type.
    Required:
返回值
  • (string) Sanitized mime type.
定義位置
相關方法
sanitize_metasanitize_keysanitize_file_namesanitize_termsanitize_title
引入
3.1.3
棄用
-

sanitize_mime_type: 這是一個WordPress的函式,可以對MIME型別進行淨化。它用於驗證和淨化MIME型別以防止錯誤: 這個函式有一個引數,就是要處理的MIME型別。

對一個MIME型別進行淨化。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function sanitize_mime_type( $mime_type ) {
$sani_mime_type = preg_replace( '/[^-+*.a-zA-Z0-9/]/', '', $mime_type );
/**
* Filters a mime type following sanitization.
*
* @since 3.1.3
*
* @param string $sani_mime_type The sanitized mime type.
* @param string $mime_type The mime type prior to sanitization.
*/
return apply_filters( 'sanitize_mime_type', $sani_mime_type, $mime_type );
}
function sanitize_mime_type( $mime_type ) { $sani_mime_type = preg_replace( '/[^-+*.a-zA-Z0-9/]/', '', $mime_type ); /** * Filters a mime type following sanitization. * * @since 3.1.3 * * @param string $sani_mime_type The sanitized mime type. * @param string $mime_type The mime type prior to sanitization. */ return apply_filters( 'sanitize_mime_type', $sani_mime_type, $mime_type ); }
function sanitize_mime_type( $mime_type ) {
	$sani_mime_type = preg_replace( '/[^-+*.a-zA-Z0-9/]/', '', $mime_type );
	/**
	 * Filters a mime type following sanitization.
	 *
	 * @since 3.1.3
	 *
	 * @param string $sani_mime_type The sanitized mime type.
	 * @param string $mime_type      The mime type prior to sanitization.
	 */
	return apply_filters( 'sanitize_mime_type', $sani_mime_type, $mime_type );
}

常見問題

FAQs
檢視更多 >