1
I need to create a . php file with the results that appear accessing another . php file, for example:
I access http://localhost/.php files and this page results me to lists of existing files on a page. For this I use this code:
<?php
$pasta = 'imagens/';
if(is_dir($pasta))
{
$diretorio = dir($pasta);
while(($arquivo = $diretorio->read()) !== false)
{
echo ''.$arquivo.'<br />';
}
$diretorio->close();
}
else
{
echo 'A pasta não existe.';
}
?>
I need the result "arquivo1.ini", "arquivo2.ini"... to be saved in a .php. file I tried to modify the page code as follows:
<?php
$filename = 'meuteste.php';
$pasta = '/xampp/htdocs/';
if(is_dir($pasta))
{
$diretorio = dir($pasta);
while(($arquivo = $diretorio->read()) !== false)
{
int file_put_contents ($filename, echo ''.$arquivo.'</a><br />');
}
}
else
{
echo 'A pasta não existe.';
}
?>
But the command is wrong, I get this message when opening http://localhost/.php files:
Parse error: syntax error, Unexpected 'file_put_contents' (T_STRING) in C: xampp htdocs lista.php on line 10
Has anyone ever been through something like this? You know the solution?
From now on, thank you.
removes that
int
before thefile_put...
– rray
Good afternoon rray, without the int, the following error appears: > Parse error: syntax error, Unexpected 'echo' (T_ECHO) in C: xampp htdocs list.php on line 10
– Wesley