sanitize_url

函式
sanitize_url ( $url, $protocols = null )
引數
  • (string) $url The URL to be cleaned.
    Required:
  • (string[]) $protocols Optional. An array of acceptable protocols. Defaults to return value of wp_allowed_protocols().
    Required:
    Default: null
返回值
  • (string) The cleaned URL after esc_url() is run with the 'db' context.
相關
  • esc_url()
定義位置
相關方法
sanitize_usersanitize_termsite_urlsanitize_emailsanitize_user_field
引入
2.3.1
棄用
-

sanitize_url: 這是一個WordPress的函式,可以對一個URL進行淨化。它用於刪除任何潛在的危險元素,如指令碼標籤或無效字元: 這個函式有一個引數,就是要淨化的URL。

為資料庫或重定向使用的URL進行淨化處理。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function sanitize_url( $url, $protocols = null ) {
return esc_url( $url, $protocols, 'db' );
}
function sanitize_url( $url, $protocols = null ) { return esc_url( $url, $protocols, 'db' ); }
function sanitize_url( $url, $protocols = null ) {
	return esc_url( $url, $protocols, 'db' );
}

常見問題

FAQs
檢視更多 >