Fardin Posted October 5, 2021 Share Posted October 5, 2021 Hi, The following code is apart of my image upload process code: $crop->new_name = $this->RandomStringGenerator() . "." . $crop->ext; $this->new_name2 = $crop->new_name; The problem is that the value in new_name2 variable is not same as variable new_name. How can I fix this issue? Quote Link to comment https://forums.phpfreaks.com/topic/313873-how-to-transfer-data-from-a-variable-to-an-another-variable/ Share on other sites More sharing options...
gw1500se Posted October 5, 2021 Share Posted October 5, 2021 Don't know unless you post more of your code. Without the function code how do we know what $this is supposed to be or how that object was initialized? Quote Link to comment https://forums.phpfreaks.com/topic/313873-how-to-transfer-data-from-a-variable-to-an-another-variable/#findComment-1590698 Share on other sites More sharing options...
gw1500se Posted October 5, 2021 Share Posted October 5, 2021 This is a guess without more detail but try: $this->new_name2 = clone $crop->new_name; Quote Link to comment https://forums.phpfreaks.com/topic/313873-how-to-transfer-data-from-a-variable-to-an-another-variable/#findComment-1590699 Share on other sites More sharing options...
ginerjm Posted October 5, 2021 Share Posted October 5, 2021 "variable new_name"? Is that a separate and distinct variable or you are just simply not specifying the object name? Quote Link to comment https://forums.phpfreaks.com/topic/313873-how-to-transfer-data-from-a-variable-to-an-another-variable/#findComment-1590700 Share on other sites More sharing options...
gizmola Posted October 5, 2021 Share Posted October 5, 2021 We need the full code of the method where you are trying to do this. The use of a local $crop variable is odd. With that said, inside a method, that line should work fine, so there is something else missing in your question. You say they are "not the same." Where is it that you find this to be the case? Quote Link to comment https://forums.phpfreaks.com/topic/313873-how-to-transfer-data-from-a-variable-to-an-another-variable/#findComment-1590703 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.