WP_Filesystem_Base::exists() WordPress Method

The WP_Filesystem_Base::exists() method is used to check whether a given file or directory exists. This is a static method, and it takes two parameters: the path to check, and an optional boolean flag specifying whether to check if the given path is a directory. This method is useful for making sure that a given file or directory exists before attempting to perform any operations on it. For example, you might use this method to check if a given image file exists before attempting to process and resize it. Note that this method only checks whether the given path exists; it does not check whether the path is readable, writable, or executable. Therefore, you should not use this method as a substitute for the WP_Filesystem_Base::is_readable(), WP_Filesystem_Base::is_writable(), or WP_Filesystem_Base::is_executable() methods.

WP_Filesystem_Base::exists( string $file ) #

Checks if a file or directory exists.


Parameters

$file

(string)(Required)Path to file or directory.


Top ↑

Return

(bool) Whether $file exists or not.


Top ↑

Source

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

	public function exists( $file ) {
		return false;
	}


Top ↑

Changelog

Changelog
VersionDescription
2.5.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.