##Don't use globals in this case##
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', "testing.html");
define('TAG', "/x-berschrift-1--nur-f-r-Header-/");
define('DIRECTORY', "testing");
Define global constants like this at the beginning of your file.
##Simplify (and remove) your functions##
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
##Misc changes## MakeMake 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.
##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', "testing.html");
define('TAG', "/x-berschrift-1--nur-f-r-Header-/");
define('DIRECTORY', "testing");
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.
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', "testing.html");
define('TAG', "/x-berschrift-1--nur-f-r-Header-/");
define('DIRECTORY', "testing");
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.
##Don't use constantsglobals 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', "testing.html");
define('TAG', "/x-berschrift-1--nur-f-r-Header-/");
define('DIRECTORY', "testing");
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 each. 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.
##Don't use constants 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', "testing.html");
define('TAG', "/x-berschrift-1--nur-f-r-Header-/");
define('DIRECTORY', "testing");
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 each. 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.
##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', "testing.html");
define('TAG', "/x-berschrift-1--nur-f-r-Header-/");
define('DIRECTORY', "testing");
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.
##Don't use constants 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', "testing.html");
define('TAG', "/x-berschrift-1--nur-f-r-Header-/");
define('DIRECTORY', "testing");
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 each. 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.