CHAPTER 15 - Testing the Extension

Computer Education, Training & Tutorial Resources - ComputerEducationWorld.com
Home » Free Computer Books » PHP » PHP 5 Power Programming »

You are now ready to write a test script to
check that the extension works. Here’s a sample script that opens a file
test.txt, prints its contents to the standard output, and creates a copy of the
file as test.txt.new:
<?php
$fp_in = file_open(”test.txt”, “r”) or die(”Unable to open input
file\n”);
$fp_out = file_open(”test.txt.new”, “w”) or die(”Unable to open
output file\n”);
while (!file_eof($fp_in)) {
$str = file_read($fp_in, 1024);
print($str);
file_write($fp_out, $str);
}
file_close($fp_in);
file_close($fp_out);
?>


• • •
 



captcha PHP Script Free PHP captcha script free php
Website Design by WebWalas.com