I am not very used to php, but I have made an index.php page to put in any folder of my private web server, in order to allow me to quickly download some docs. It works fine, except that I tried to add the file size. That part of the code just displays “filesize” instead of the size itself. Can someone help to fix this?
<h1>My tools</h1>
<?php
$dirname = ".";
$dir = opendir($dirname);
while(false != ($file = readdir($dir)))
{
if(($file != ".") and ($file != "..") and ($file != "index.php"))
{
echo("<a href='$file'>$file</a> filesize($file) <br />");
}
}
?>
You can’t embed anything like that. In your case PHP has no way of knowing if you want to call the
filesizefunction or you just want that text printed out so it was built to interpret your format as text instead of a function call, that being the safe option.See here for what you are allowed to put inside double quoted strings: http://www.php.net/manual/en/language.types.string.php#language.types.string.parsing