Microsoft Word - Core PHP Programming Using PHP to Build Dynamic Web Sites

(singke) #1

<?
// open file for writing
$myFile = fopen("data.txt","w");


// make sure the open was successful
if(!($myFile))
{
print("file could not be opened");
exit;
}


for($index=0; $index<10; $index++)
{
// write a line to the file
fputs($myFile, "line $index\n");
}


// close the file
fclose($myFile);
?>


array get_meta_tags(string filename, boolean
use_include_path)


The get_meta_tags function opens a file and scans for HTML meta tags. The function
assumes it is a well-formed HTML file that uses native line breaks. An array indexed by
the name attribute of the meta tag is returned. If the name contains any characters illegal
in identifiers, they will be replaced with underscores. This helps if you wish to make all
the elements of the ar-ray into variables using extract, a function discussed in Chapter
9, "Data Functions."


The optional use_include_path will cause get_meta_tags to look for the file in the
include path instead of the current directory. The include path is set in php.ini and
normally is used by the include function.


Like many of the file functions, get_meta_tags allows specifying a URL instead of a
path on the local filesystem.


Figure 8-3. get_meta_tags.
Free download pdf