PHP 클래스 F

상속: extends E
파일 보기 프로젝트 열기: getkirby/toolkit 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$mimes
$types
$units

공개 메소드들

메소드 설명
append ( string $file, mixed $content ) : boolean Appends new content to an existing file
base64 ( string $file ) : string Returns the file content as base64 encoded string
copy ( string $file, string $target ) : boolean Copy a file to a new location.
dirname ( string $file ) : string Just an alternative for dirname() to stay consistent
download ( $file, $name = null ) * Automatically sends all needed headers for the file to be downloaded and echos the file's content
exists ( string $file ) : boolean Checks if a file exists
extension ( string $file, string $extension = false ) : string Gets the extension of a file
extensionToMime ( string $extension ) : string Converts a file extension to a mime type
extensionToType ( string $extension ) : string Returns the file type for a passed extension
extensions ( string $type = null ) : array Returns all extensions for a certain file type
filename ( string $name ) : string Extracts the filename from a file path
is ( string $file, string $value ) : boolean Checks if a file is of a certain type
isReadable ( string $file ) : boolean Checks if the file is readable
isWritable ( string $file ) : boolean Checks if the file is writable
load ( $file, $data = [] ) Safely requires a file if it exists
mime ( string $file ) : mixed Returns the mime type of a file
mimeToExtension ( string $mime ) : string Converts a mime type to a file extension
mimeToType ( string $mime ) : string Returns the type for a given mime
mimes ( ) : array Returns all detectable mime types
modified ( string $file, string $format = null, string $handler = 'date' ) : integer Get the file's last modification time.
move ( string $old, string $new ) : boolean Moves a file to a new location
name ( string $name ) : string Extracts the name from a file path or filename without extension
niceSize ( mixed $size ) : string Converts an integer size into a human readable format
read ( string $file ) : mixed Reads the content of a file
remove ( string $file ) : boolean Deletes a file
resolve ( string $base, array $extensions ) : string | false Tries to find a file by various extensions
safeName ( string $string ) : string Sanitize a filename to strip unwanted special characters
show ( string $file ) Read and send the file with the correct headers
size ( mixed $file ) : mixed Returns the size of a file.
type ( string $file ) : string Categorize the file
types ( ) : array Returns an array of all available file types
unzip ( string $file, string $to ) : boolean Unzips a zip file
uri ( string $file ) : string Returns the file as data uri
write ( string $file, mixed $content, boolean $append = false ) : boolean Creates a new file

메소드 상세

append() 공개 정적인 메소드

Appends new content to an existing file
public static append ( string $file, mixed $content ) : boolean
$file string The path for the file
$content mixed Either a string or an array. Arrays will be converted to JSON.
리턴 boolean

base64() 공개 정적인 메소드

Returns the file content as base64 encoded string
public static base64 ( string $file ) : string
$file string The path for the file
리턴 string

copy() 공개 정적인 메소드

Copy a file to a new location.
public static copy ( string $file, string $target ) : boolean
$file string
$target string
리턴 boolean

dirname() 공개 정적인 메소드

$dirname = f::dirname('/var/www/test.txt'); dirname is /var/www
public static dirname ( string $file ) : string
$file string The path
리턴 string

download() 공개 정적인 메소드

* Automatically sends all needed headers for the file to be downloaded and echos the file's content
public static download ( $file, $name = null )
$file The root to the file
$name Optional filename for the download

exists() 공개 정적인 메소드

Checks if a file exists
public static exists ( string $file ) : boolean
$file string
리턴 boolean

extension() 공개 정적인 메소드

$extension = f::extension('test.txt'); extension is txt
public static extension ( string $file, string $extension = false ) : string
$file string The filename or path
$extension string Set an optional extension to overwrite the current one
리턴 string

extensionToMime() 공개 정적인 메소드

Converts a file extension to a mime type
public static extensionToMime ( string $extension ) : string
$extension string
리턴 string

extensionToType() 공개 정적인 메소드

Returns the file type for a passed extension
public static extensionToType ( string $extension ) : string
$extension string
리턴 string

extensions() 공개 정적인 메소드

Returns all extensions for a certain file type
public static extensions ( string $type = null ) : array
$type string
리턴 array

filename() 공개 정적인 메소드

$filename = f::filename('/var/www/test.txt'); filename is test.txt
public static filename ( string $name ) : string
$name string The path
리턴 string

is() 공개 정적인 메소드

Checks if a file is of a certain type
public static is ( string $file, string $value ) : boolean
$file string Full path to the file
$value string An extension or mime type
리턴 boolean

isReadable() 공개 정적인 메소드

Checks if the file is readable
public static isReadable ( string $file ) : boolean
$file string
리턴 boolean

isWritable() 공개 정적인 메소드

Checks if the file is writable
public static isWritable ( string $file ) : boolean
$file string
리턴 boolean

load() 공개 정적인 메소드

Safely requires a file if it exists
public static load ( $file, $data = [] )

mime() 공개 정적인 메소드

Returns the mime type of a file
public static mime ( string $file ) : mixed
$file string
리턴 mixed

mimeToExtension() 공개 정적인 메소드

Converts a mime type to a file extension
public static mimeToExtension ( string $mime ) : string
$mime string
리턴 string

mimeToType() 공개 정적인 메소드

Returns the type for a given mime
public static mimeToType ( string $mime ) : string
$mime string
리턴 string

mimes() 공개 정적인 메소드

Returns all detectable mime types
public static mimes ( ) : array
리턴 array

modified() 공개 정적인 메소드

Get the file's last modification time.
public static modified ( string $file, string $format = null, string $handler = 'date' ) : integer
$file string
$format string
$handler string date or strftime
리턴 integer

move() 공개 정적인 메소드

$move = f::move('test.txt', 'super.txt'); if($move) echo 'The file has been moved';
public static move ( string $old, string $new ) : boolean
$old string The current path for the file
$new string The path to the new location
리턴 boolean

name() 공개 정적인 메소드

$name = f::name('/var/www/test.txt'); name is test
public static name ( string $name ) : string
$name string The path or filename
리턴 string

niceSize() 공개 정적인 메소드

$niceSize = f::niceSize('/path/to/a/file.txt'); nice size is i.e: 212 kb $niceSize = f::niceSize(1231939); nice size is: 1,2 mb
public static niceSize ( mixed $size ) : string
$size mixed The file size or a file path
리턴 string

read() 공개 정적인 메소드

$content = f::read('test.txt'); i.e. content is hello $content = f::read('text.txt', 'json'); returns an array with the parsed content
public static read ( string $file ) : mixed
$file string The path for the file
리턴 mixed

remove() 공개 정적인 메소드

$remove = f::remove('test.txt'); if($remove) echo 'The file has been removed';
public static remove ( string $file ) : boolean
$file string The path for the file
리턴 boolean

resolve() 공개 정적인 메소드

Tries to find a file by various extensions
public static resolve ( string $base, array $extensions ) : string | false
$base string
$extensions array
리턴 string | false

safeName() 공개 정적인 메소드

$safe = f::safeName('über genious.txt'); safe will be ueber-genious.txt
public static safeName ( string $string ) : string
$string string The file name
리턴 string

show() 공개 정적인 메소드

Read and send the file with the correct headers
public static show ( string $file )
$file string

size() 공개 정적인 메소드

$size = f::size('/var/www/test.txt'); size is ie: 1231939
public static size ( mixed $file ) : mixed
$file mixed The path
리턴 mixed

type() 공개 정적인 메소드

Categorize the file
public static type ( string $file ) : string
$file string Either the file path or extension
리턴 string

types() 공개 정적인 메소드

Returns an array of all available file types
public static types ( ) : array
리턴 array

unzip() 공개 정적인 메소드

Unzips a zip file
public static unzip ( string $file, string $to ) : boolean
$file string
$to string
리턴 boolean

uri() 공개 정적인 메소드

Returns the file as data uri
public static uri ( string $file ) : string
$file string The path for the file
리턴 string

write() 공개 정적인 메소드

f::write('test.txt', 'hello'); creates a new text file with hello as content create a new file f::write('text.txt', array('test' => 'hello')); creates a new file and encodes the array as json
public static write ( string $file, mixed $content, boolean $append = false ) : boolean
$file string The path for the new file
$content mixed Either a string, an object or an array. Arrays and objects will be serialized.
$append boolean true: append the content to an exisiting file if available. false: overwrite.
리턴 boolean

프로퍼티 상세

$mimes 공개적으로 정적으로 프로퍼티

public static $mimes

$types 공개적으로 정적으로 프로퍼티

public static $types

$units 공개적으로 정적으로 프로퍼티

public static $units