PHP and Javascript: Getting file contents with Javascript variable

Posted by celliott1997 on Stack Overflow See other posts from Stack Overflow or by celliott1997
Published on 2013-10-23T21:42:46Z Indexed on 2013/10/23 21:54 UTC
Read the original article Hit count: 145

Filed under:
|
|
|

Could someone help me to understand why this isn't working?

var uname = "<?php echo strtolower($_GET['un']) ?>";
var source = "<?php echo file_get_contents('accounts/"+uname+"') ?>";
console.log(source);

I've been trying for a while to get this working and it just doesn't seem to. Before I added in the source variable, it was working fine and displayed the un variable on the page.

Thanks.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about php