I have a code to list all my directory without extension and it works well. The thing is when I want to add some php<> before and after, that transform my <?php ?>
in <!-- -->
. I don't know why.
Any thoughts?
<?php
$variables = '';
$handle = '';
$variablesfile = '';
// open my directory
if ($handle = opendir($_SERVER['DOCUMENT_ROOT'].'/mvi/index/graphic-documents/sozie/variables/')) {
// list directory contents
while (false !== ($variablesfile = readdir($handle))) {
// exeptions
if (($variablesfile != ".")
&& ($variablesfile != "..")
&& ($variablesfile != "index.php")
&& ($variablesfile != "compiler.php")
&& ($variablesfile != ".DS_Store"))
// only grab file names
if (is_file($_SERVER['DOCUMENT_ROOT'].'/my/path/'. $variablesfile)) {
$file_name = $variablesfile;
$file_array = explode('.',$file_name);
$extension = count($file_array) - 2;
$no_extension = substr($file_name,0,strlen($file_array[$extension]));
// creation of php code
$variables .= '<?php $'.$no_extension.' = file_get_contents($_SERVER["DOCUMENT_ROOT"]."/my/path/'.$no_extension.'.txt") ; ?>'. "\n" ;
}
}
closedir($handle);
echo $variables ;
}
?>
Result on inspector:
What should be
<?php $variable = file_get_contents($_SERVER["DOCUMENT_ROOT"]."/my/path/variable.txt") ; ?>
is
<!-- ?php $variable = file_get_contents($_SERVER["DOCUMENT_ROOT"]."/my/path/variable.txt") ; ? -->
If I check my source code from Chrome, the <?php ?>
displays well.....
Everything works fine everywhere else.. I have checked my apache and I'm running in localhost..So everything is ok on that side.