SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 480 | Next

James Kennard

"Mastering Joomla! 1.5 Extension and Framework Development"

This method returns a
Boolean response. This example deletes the file foo.php from the frontend root of
the current component:
if (!JFile::delete(JPATH_COMPONENT.DS.'foo.php'))
{
// handle failed delete
}
If we want to delete multiple files at once, we can pass an array of file paths to the
delete() method. This example deletes the files foo.php and bar.php from the
frontend root of the current component:
$files = array(JPATH_COMPONENT.DS.'foo.php',
JPATH_COMPONENT.DS.'bar.php');
if (!JFile::delete($files))
{
// handle failed delete
}
The next two methods we will look at are used to read and write data to and from
files. These methods are aptly named read() and write(). We'll start by using the
read() method to access the contents of a file:
$file = JPATH_COMPONENT.DS.'foo.php';
$contents = JFile::read($file);
The contents of the file is read into the $contents variable as a string. If the read()
method is unsuccessful, the method returns false. It is not uncommon, once a file
is successfully read, to use the explode() function to split the contents into an array
of lines:
$lines = explode("\n", $contents);
To write to a file we use a similar approach.


Pages:
468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6