Showing posts with label built in function of php. Show all posts
Showing posts with label built in function of php. Show all posts

Monday, 23 November 2015

phpFile Managment

php File Managment:

 Alright i am back after a long time so ... my new topic from today file management , no doubt its play an important role for any programming language its also important for php as well.
so i am starting from basic for file management operations.

we need to open a file,read a file ,do some modifications in files, i will discuss today how to read files in php.

Example:


<?php

// read files from my destination
$file = 'destination/phpguidefile.txt' or die('file not Found');
// to open file we use fopen
$fh = fopen($file, 'r') or die('file unable to open');
// to read file data/text use fread
$content = fread($fh, filesize($file)) or die('Reading Error');
// also its important to close file use fclose
fclose($fh);
// Echo text/data from file in php script
echo $content;

?>

Saturday, 31 October 2015

Read All Files From Directory

If we want to read all files name or specific files name from directory , no need of worry php provide B.I.F(built in function) name as glob().

What this method do?
glob search path name with provide patterns and fetch all related files.

glob('dirname'/*.*');
above method will fetch all files with any extensions we can also fetch particular extensions using below syntax
glob('*.ext');

Tuesday, 30 December 2014

Use B.I.F Of Php for Variables

first of all let you know what is B.I.F ? its just built in function of php ;) nothing new 

  • strtolower()
  • strtoupper()
  • ucfirst()
  • lcfirst()
  • ucwords()