11.07.2015 Views

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 10 • WORKING WITH THE FILE AND OPERATING SYSTEMwww.it-ebooks.info}// Assign each SSN part to an appropriate variablelist ($part1,$part2,$part3) = $user;printf(“Part 1: %d Part 2: %d Part 3: %d ", $part1, $part2, $part3);fclose($fh);?>With each iteration, the variables $part1, $part2, and $part3 are assigned the three components ofeach SSN, respectively, and output to the browser.Writing a String to a FileThe fwrite() function outputs the contents of a string variable to the specified resource. Its prototypefollows:int fwrite(resource handle, string string [, int length])If the optional length parameter is provided, fwrite() will stop writing when length characters havebeen written. Otherwise, writing will stop when the end of the string is found. Consider this example:// Data we'd like to write to the subscribers.txt file$subscriberInfo = 'Jason Gilmore|jason@example.com';// Open subscribers.txt for writing$fh = fopen('/home/www/data/subscribers.txt', 'a');// Write the datafwrite($fh, $subscriberInfo);// Close the handlefclose($fh);■ Tip If the optional length parameter is supplied to fwrite(), the magic_quotes_runtime configurationparameter will be disregarded. See Chapters 2 and 9 for more information about this parameter. This only appliesto <strong>PHP</strong> 5.3 and earlier, as <strong>PHP</strong>'s magic quoting feature has been deprecated with this release.246

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!