Current Location: Home> Function Categories> fgetss

fgetss

Read a line from a file pointer and filter out HTML tags
Name:fgetss
Category:File system
Programming Language:php
One-line Description:Read a line from the open file and filter out HTML and PHP tags.

Example

Example 1

 <span class="token php language-php"><span class="token delimiter important"><?php</span>

<span class="token variable">$file</span> <span class="token operator">=</span> <span class="token function">fopen</span> <span class="token punctuation">(</span> <span class="token string double-quoted-string">"test.htm"</span> <span class="token punctuation">,</span> <span class="token string double-quoted-string">"r"</span> <span class="token punctuation">)</span> <span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token function">fgetss</span> <span class="token punctuation">(</span> <span class="token variable">$file</span> <span class="token punctuation">)</span> <span class="token punctuation">;</span>
<span class="token function">fclose</span> <span class="token punctuation">(</span> <span class="token variable">$file</span> <span class="token punctuation">)</span> <span class="token punctuation">;</span>

<span class="token delimiter important">?></span></span>

The output is similar:

 This is a paragraph.

Example 2

 <span class="token php language-php"><span class="token delimiter important"><?php</span>

<span class="token variable">$file</span> <span class="token operator">=</span> <span class="token function">fopen</span> <span class="token punctuation">(</span> <span class="token string double-quoted-string">"test.htm"</span> <span class="token punctuation">,</span> <span class="token string double-quoted-string">"r"</span> <span class="token punctuation">)</span> <span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token function">fgetss</span> <span class="token punctuation">(</span> <span class="token variable">$file</span> <span class="token punctuation">,</span> <span class="token number">1024</span> <span class="token punctuation">,</span> <span class="token string double-quoted-string">"<p>,<b>"</span> <span class="token punctuation">)</span> <span class="token punctuation">;</span>
<span class="token function">fclose</span> <span class="token punctuation">(</span> <span class="token variable">$file</span> <span class="token punctuation">)</span> <span class="token punctuation">;</span>

<span class="token delimiter important">?></span></span>

The output is similar:

 <b>This is a paragraph.</b>

The output source code is:

 <span class="token operator"><</span> p <span class="token operator">></span> <span class="token operator"><</span> b <span class="token operator">></span> This is a paragraph <span class="token operator">.</span> <span class="token operator"><</span> <span class="token operator">/</span> b <span class="token operator">></span> <span class="token operator"><</span> <span class="token operator">/</span> p <span class="token operator">></span>
Similar Functions
  • Determine whether the given file name is a normal file is_file

    is_file

    Determinewhethertheg
  • Test whether the file pointer reaches the end of the file feof

    feof

    Testwhetherthefilepo
  • Rename a file or directory rename

    rename

    Renameafileordirecto
  • Create a temporary file tmpfile

    tmpfile

    Createatemporaryfile
  • Format input from a file fscanf

    fscanf

    Formatinputfromafile
  • Open a file or URL fopen

    fopen

    OpenafileorURL
  • Rewind the file pointer position rewind

    rewind

    Rewindthefilepointer
  • Get the file owner fileowner

    fileowner

    Getthefileowner