PHP Tutorials
71. Install and use PHPUnit to test your PHP pages for errors.
By: Emiley J : 2009-01-14
Description: Warning: require_once(PHPUnit/Framework.php) [function.require-once]: failed to open stream: No such file or directory If you are getting this error, the most obvious reason is you do not have the PHPUnit installed in your web server. To install the PHPUnit in your server follow the steps below.
72. Using Codeigniter for PHP application development
By: Benny Alexander : 2008-12-29
Description: With many software frameworks available online nowadays, with many pros and cons on their side, it has become very important to check out complete details of these frameworks before applying them. Amongst the various kinds of software frameworks, the PHP Framework is more popular nowadays. Being simple to work on and easy to use, PHP frameworks are soon becoming the catchword of software frameworks
73. Reading .ini files in PHP
By: David Sklar : 2008-12-01
Description: The function parse_ini_file() reads configuration files structured like PHP's main php.ini file. Instead of applying the settings in the configuration file to PHP's configuration, however, parse_ini_file() returns the values from the file in an array.
74. Creating or Opening a File in PHP
By: David Sklar : 2008-12-01
Description: The first argument to fopen()is the file to open; the second argument is the mode to open the file in. The mode specifies what operations can be performed on the file (reading and/or writing), where the file pointer is placed after the file is opened (at the beginning or end of the file), whether the file is truncated to zero length after opening, and whether the file is created if it doesn't exist, as shown in Table below.
75. Opening a Remote File in PHP
By: David Sklar : 2008-12-01
Description: When fopen() is passed a filename that begins with http://, it retrieves the given page with an HTTP/1.0 GET request (although a Host: header is also passed along to deal with virtual hosts). Only the body of the reply can be accessed using the file handle, not the headers. Files can be read, not written, via HTTP.
76. Reading contents of a File into a String in PHP
By: David Sklar : 2008-12-01
Description: You want to load the entire contents of a file into a variable. For example, you want to determine if the text in a file matches a regular expression. Use filesize()to get the size of the file, and then tell fread() to read that many bytes
77. Counting Lines, Paragraphs, or Records in a File using pc_split_paragraphs() in PHP
By: David Sklar : 2008-12-01
Description: You want to count the number of lines, paragraphs, or records in a file.To count lines, use fgets(). Because it reads a line at a time, you can count the number of times it's called before reaching the end of a file:
78. Reading word by word from a file in PHP
By: David Sklar : 2008-12-01
Description: Processing every word proceeds differently depending on how "word" is defined. The code in this recipe uses the Perl-compatible regular-expression engine's \s whitespace metacharacter, which includes space, tab, newline, carriage return, and formfeed. Code sample above breaks apart a line into words by splitting on a space, which is useful in that recipe because the words have to be rejoined with spaces. The Perl-compatible engine also has a word-boundary assertion (\b) that matches between a word character (alphanumeric) and a nonword character (anything else). Using \b instead of \s to delimit words most noticeably treats differently words with embedded punctuation. The term 6 o'clock is two words when split by whitespace (6 and o'clock); it's four words when split by word boundaries (6, o, ', and clock).
79. Reading and Writing .gz files in PHP
By: David Sklar : 2008-12-01
Description: The zlib extension contains versions of many file-access functions, such as fopen(), fread(), and fwrite() (called gzopen(), gzread(), gzwrite(), etc.) that transparently compress data when writing and uncompress data when reading. The compression algorithm that zlib uses is compatible with the gzip and gunzip utilities.
80. Extract files from a .zip file using PHP
By: David Sklar : 2008-12-01
Description: The unzip.php sample program below, extracts files from a ZIP archive. It uses the pc_mkdir_parents() function. The program also requires PHP's zip extension to be installed. You can find documentation on the zip extension at http://www.php.net/zip.