Scrape HTML into separate files for each chapter I have written a program to read HTML file, find particular text, write text from that particular text to next particular text in a newly opened file. I am interested in code review. I am very new PHP.

&lt;?php

$FILE = "testing.html";
$count = 0;
$directoryName = explode('.',$FILE)[0];
$TAG = "/x-berschrift-1--nur-f-r-Header-/";

function readingFile($FILE)
{
    //Creates a directory on the file name to store segmeted chapters from $FILE
    global $directoryName;
    mkdir($directoryName);
    $file_handle = fopen($FILE, "r");
    chdir($directoryName);
    $matchTag = False;
    while (!feof($file_handle))
     {
           $line = fgets($file_handle);
           if(checkingMatchTag($line))
           {
                if($matchTag){
                    closeWriteFile($writeHandle);
                    incrementCounter();
                }
                else
                {
                    $matchTag = True;
                }
                $writeHandle = openWriteFile();
                segmentContent($writeHandle, $line);
           }        
           elseif($matchTag)
           {
               segmentContent($writeHandle, $line); 
           }
     } 
}

function checkingMatchTag($line)
{
    global $TAG;
    if(preg_match($TAG, $line))
    {
        return True;
    }
    return False;
}

function openWriteFile()
{
    global $directoryName, $count, $FILE;
    $writingFile = fopen($directoryName.$count.'.'.explode('.',$FILE)[1], 'w');
    return $writingFile;
}

function segmentContent($writeFileHandle, $line)
{
   fwrite($writeFileHandle, $line);
}


function closeWriteFile($file)
{
    fclose($file);
}

function incrementCounter()
{
    global $count;
    $count++;
}


readingFile($FILE);
Don't use globals in this case
To start off, global variables should generally be avoided.  Often times configurations will use global constants, but using global variables can have implications to the namespace.  See pacmaninbw's answer for a little more explanation on that.
With that said,  if you wanted to keep the values global please use constants.
define('FILE', &quot;testing.html&quot;);
define('TAG', &quot;/x-berschrift-1--nur-f-r-Header-/&quot;);
define('DIRECTORY', &quot;testing&quot;);

Define global constants like this at the beginning of your file.

Simplify (and remove) your functions
Next up are your functions:
function checkingMatchTag($line)
{
    return preg_match(TAG, $line);
}

function openWriteFile($directory, $count, $extension)
{
    return fopen($directory . $count . '.' . $extension, 'w');
}

function closeWriteFile($file)
{
    fclose($file);
}

function segmentContent($writeFileHandle, $line)
{
    fwrite($writeFileHandle, $line);
}

As you can see, I simplified your functions for you.  They perform the same, but have less clutter involved. In checkingMatchTag I left in the call to TAG in to show you how to call global constants.
Anyway, the point is each of these functions can be reduced to one simple line.  So why are you making a ton of functions for one line of basic code?  I would advise you get rid of each of these functions and simply use the line of code.

Misc changes
Make sure the directory is not there by using this code:
if (!file_exists(DIRECTORY)) {
    mkdir(DIRECTORY);
}

Use the same naming convention for everything. Look at your perimeters. Look at your spacing.  Look at your {}.  There are differences in all of them.