The below code determines the missing bracket issue in php file.
<?php
$file_path = "../www/class.php"; //privide here the name of the file
$code = file_get_contents($file_path);
$code_is_valid = preg_match('~^({ ( (?>[^{}]+) | (?1) )* })$~x', '{' . $code .'}');
if($code_is_valid == 1)
{
echo "No bracket issue found";
}
else
{
echo "Error,opening/closing bracket missing";
}
?>
<?php
$file_path = "../www/class.php"; //privide here the name of the file
$code = file_get_contents($file_path);
$code_is_valid = preg_match('~^({ ( (?>[^{}]+) | (?1) )* })$~x', '{' . $code .'}');
if($code_is_valid == 1)
{
echo "No bracket issue found";
}
else
{
echo "Error,opening/closing bracket missing";
}
?>
No comments:
Post a Comment