anolan13 Posted June 3, 2008 Share Posted June 3, 2008 Hello, For awhile now I've used code to get the size of a folders content (folder "files") on my server, this is the line that is now causing me trouble... $total = total_size('files/'); But now I want that folder to be a variable instead so maybe the folder is named "files" or "dogs" or "oranges" or anything...so I picture the new line of code being something like this $total = total_size('$files/'); Where $files is a variable, but it just wont work. I've tried everything, removing the ' 's ... the / I've played around with it for a long time and I get nothing. So how do I make this work? Any help is greatly appreciated, Thanks! Link to comment https://forums.phpfreaks.com/topic/108477-solved-put-a-variable-in-another-variable-somehow/ Share on other sites More sharing options...
ikmyer Posted June 3, 2008 Share Posted June 3, 2008 try... $total = total_size("$files/"); Link to comment https://forums.phpfreaks.com/topic/108477-solved-put-a-variable-in-another-variable-somehow/#findComment-556183 Share on other sites More sharing options...
raku Posted June 3, 2008 Share Posted June 3, 2008 I'm not sure I understand what you're asking entirely, but you could try something like this: $files = "files/"; $total = total_size($files); Hope this helps. Link to comment https://forums.phpfreaks.com/topic/108477-solved-put-a-variable-in-another-variable-somehow/#findComment-556184 Share on other sites More sharing options...
mushroom Posted June 3, 2008 Share Posted June 3, 2008 I have found that some functions do not work with compound variables....... solution give the function a simple variable $files=$files."/"; $total = total_size('$files'); Link to comment https://forums.phpfreaks.com/topic/108477-solved-put-a-variable-in-another-variable-somehow/#findComment-556191 Share on other sites More sharing options...
kenrbnsn Posted June 3, 2008 Share Posted June 3, 2008 Variables surrounded by single quotes are not evaluated. This should work: <?php $total = total_size($files . '/'); ?> If that doesn't work, please show use the code for the total_size function. Ken Link to comment https://forums.phpfreaks.com/topic/108477-solved-put-a-variable-in-another-variable-somehow/#findComment-556220 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.