ChrisMartino Posted January 17, 2010 Share Posted January 17, 2010 Ok so i want to do this somebody please tell me if it would work? " $filedir = "/file/path/$username"; " Quote Link to comment https://forums.phpfreaks.com/topic/188823-variable-in-a-variable/ Share on other sites More sharing options...
Alex Posted January 17, 2010 Share Posted January 17, 2010 $var = '$filedir = "/file/path/$username";'; Quote Link to comment https://forums.phpfreaks.com/topic/188823-variable-in-a-variable/#findComment-996859 Share on other sites More sharing options...
ChrisMartino Posted January 17, 2010 Author Share Posted January 17, 2010 can var be anything? Quote Link to comment https://forums.phpfreaks.com/topic/188823-variable-in-a-variable/#findComment-996861 Share on other sites More sharing options...
Alex Posted January 17, 2010 Share Posted January 17, 2010 Yes. Quote Link to comment https://forums.phpfreaks.com/topic/188823-variable-in-a-variable/#findComment-996863 Share on other sites More sharing options...
ChrisMartino Posted January 18, 2010 Author Share Posted January 18, 2010 This doesn't even work :/ $var = '$upload_path = "/Main/Uploads/$User";'; echo $upload_path; Quote Link to comment https://forums.phpfreaks.com/topic/188823-variable-in-a-variable/#findComment-996884 Share on other sites More sharing options...
Buddski Posted January 18, 2010 Share Posted January 18, 2010 Its because your $var contains a string.. It does not set any variable.. Ive never seen anybody try and set a variable in that manner. What exactly is this for? There is probably a valid way to do this.. Quote Link to comment https://forums.phpfreaks.com/topic/188823-variable-in-a-variable/#findComment-996887 Share on other sites More sharing options...
ChrisMartino Posted January 18, 2010 Author Share Posted January 18, 2010 Its the upload path of the file i need it to upload the file to the dir /Main/Uploads/$username $username is there username that there logged in with, I need the file to be there username :/ Quote Link to comment https://forums.phpfreaks.com/topic/188823-variable-in-a-variable/#findComment-996894 Share on other sites More sharing options...
oni-kun Posted January 18, 2010 Share Posted January 18, 2010 Do you mean $var = $upload_path = "/Main/Uploads/$username"; echo $upload_path; // Returns /Main/Uploads/Foobar echo $var; // Returns /Main/Uploads/Foobar You can assign two variables at once, but your original 'variable within a variable' question doesn't make so much sense. That $var = .. I'm not sure why you're doing, you can just do: $upload_path = "/Main/Uploads/$username"; And it will fill the $username variable accordingly. Quote Link to comment https://forums.phpfreaks.com/topic/188823-variable-in-a-variable/#findComment-996895 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.