get_contents example


    public function copy( $source$destination$overwrite = false, $mode = false ) {
        if ( ! $overwrite && $this->exists( $destination ) ) {
            return false;
        }

        $content = $this->get_contents( $source );

        if ( false === $content ) {
            return false;
        }

        return $this->put_contents( $destination$content$mode );
    }

    /** * Moves a file or directory. * * After moving files or directories, OPcache will need to be invalidated. * * If moving a directory fails, `copy_dir()` can be used for a recursive copy. * * Use `move_dir()` for moving directories with OPcache invalidation and a * fallback to `copy_dir()`. * * @since 2.7.0 * * @param string $source Path to the source file or directory. * @param string $destination Path to the destination file or directory. * @param bool $overwrite Optional. Whether to overwrite the destination if it exists. * Default false. * @return bool True on success, false on failure. */


    /** * Reads entire file into an array. * * @since 2.5.0 * * @param string $file Path to the file. * @return array|false File contents in an array on success, false on failure. */
    public function get_contents_array( $file ) {
        return explode( "\n", $this->get_contents( $file ) );
    }

    /** * Writes a string to a file. * * @since 2.5.0 * * @param string $file Remote path to the file where to write the data. * @param string $contents The data to write. * @param int|false $mode Optional. The file permissions as octal number, usually 0644. * Default false. * @return bool True on success, false on failure. */


    /** * Reads entire file into an array. * * @since 2.5.0 * * @param string $file Path to the file. * @return array|false File contents in an array on success, false on failure. */
    public function get_contents_array( $file ) {
        return explode( "\n", $this->get_contents( $file ) );
    }

    /** * Writes a string to a file. * * @since 2.5.0 * * @param string $file Remote path to the file where to write the data. * @param string $contents The data to write. * @param int|false $mode Optional. The file permissions as octal number, usually 0644. * Default false. * @return bool True on success, false on failure. */
Home | Imprint | This part of the site doesn't use cookies.