WP_Filesystem_Base::is_binary() WordPress Method

The WP_Filesystem_Base::is_binary() method is used to check if a file is binary or not. This is useful when dealing with text files, as some text editors will treat binary files as if they are text files.

WP_Filesystem_Base::is_binary( string $text ) #

Determines if the string provided contains binary characters.


Parameters

$text

(string)(Required)String to test against.


Top ↑

Return

(bool) True if string is binary, false otherwise.


Top ↑

Source

File: wp-admin/includes/class-wp-filesystem-base.php

	public function is_binary( $text ) {
		return (bool) preg_match( '|[^\x20-\x7E]|', $text ); // chr(32)..chr(127)
	}

Top ↑

Changelog

Changelog
VersionDescription
2.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.