Andrew Liu Andrew Liu - 4 months ago 12
PHP Question

PHP how to write echo inside a copy function

Pretty straight forward. I want to do something like this:

copy("/home/website/website.org/users/test.php", "/home/website/website.org/users/user/echo $_SESSION['name'];.html");


However, it doesn't seem to work.

Answer

You can't echo something when you're in the middle of the statement. Concatenate it instead:

 copy("/home/website/website.org/users/test.php", "/home/website/website.org/users/user/".$_SESSION['name'].".html");